diff options
author | Neal Norwitz <nnorwitz@gmail.com> | 2006-06-29 04:10:08 (GMT) |
---|---|---|
committer | Neal Norwitz <nnorwitz@gmail.com> | 2006-06-29 04:10:08 (GMT) |
commit | b15ac3169d5958e294e09f8daeab0f413e76d0a3 (patch) | |
tree | ff74792d40f2cc3df15e253a431d74db40d7cfdd /Lib/test/test_support.py | |
parent | 10497c83ec9aaaedf89fbe7b79e27f2890fb6695 (diff) | |
download | cpython-b15ac3169d5958e294e09f8daeab0f413e76d0a3.zip cpython-b15ac3169d5958e294e09f8daeab0f413e76d0a3.tar.gz cpython-b15ac3169d5958e294e09f8daeab0f413e76d0a3.tar.bz2 |
Add new utility function, reap_children(), to test_support. This should
be called at the end of each test that spawns children (perhaps it
should be called from regrtest instead?). This will hopefully prevent
some of the unexplained failures in the buildbots (hppa and alpha)
during tests that spawn children. The problems were not reproducible.
There were many zombies that remained at the end of several tests.
In the worst case, this shouldn't cause any more problems,
though it may not help either. Time will tell.
Diffstat (limited to 'Lib/test/test_support.py')
-rw-r--r-- | Lib/test/test_support.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/Lib/test/test_support.py b/Lib/test/test_support.py index 8e31549..6532c79 100644 --- a/Lib/test/test_support.py +++ b/Lib/test/test_support.py @@ -475,3 +475,24 @@ def threading_cleanup(num_active, num_limbo): while len(threading._limbo) != num_limbo and count < _MAX_COUNT: count += 1 time.sleep(0.1) + +def reap_children(): + """Use this function at the end of test_main() whenever sub-processes + are started. This will help ensure that no extra children (zombies) + stick around to hog resources and create problems when looking + for refleaks. + """ + + # Reap all our dead child processes so we don't leave zombies around. + # These hog resources and might be causing some of the buildbots to die. + import os + if hasattr(os, 'waitpid'): + any_process = -1 + while True: + try: + # This will raise an exception on Windows. That's ok. + pid, status = os.waitpid(any_process, os.WNOHANG) + if pid == 0: + break + except: + break |