[2.7] bpo-31160: Backport reap_children fixes from master to 2.7 (#3063)
* bpo-31160: regrtest now reaps child processes (#3044)
Add a post_test_cleanup() function which currently only calls
support.reap_children().
(cherry picked from commit e3510d74aacc477c30f42f2b941d69689bbc478e)
* bpo-31160: test_tempfile: Fix reap_children() warning (#3056)
TestRandomNameSequence.test_process_awareness() now calls
os.waitpid() to avoid leaking a zombie process.
(cherry picked from commit 6c8c2943d996b59a48d331f61f22cbe72933910e)
diff --git a/Lib/test/regrtest.py b/Lib/test/regrtest.py
index 7a48475..7096de8 100755
--- a/Lib/test/regrtest.py
+++ b/Lib/test/regrtest.py
@@ -1172,6 +1172,9 @@
return False
+def post_test_cleanup():
+ test_support.reap_children()
+
def runtest_inner(test, verbose, quiet, huntrleaks=False, pgo=False, testdir=None):
test_support.unload(test)
if verbose:
@@ -1205,6 +1208,7 @@
refleak = dash_R(the_module, test, indirect_test,
huntrleaks)
test_time = time.time() - start_time
+ post_test_cleanup()
finally:
sys.stdout = save_stdout
except test_support.ResourceDenied, msg: