diff options
author | Richard Oudkerk <shibturn@gmail.com> | 2013-08-29 13:37:47 (GMT) |
---|---|---|
committer | Richard Oudkerk <shibturn@gmail.com> | 2013-08-29 13:37:47 (GMT) |
commit | e0d25ce1fe1fe4379776c6bbb12981aabda865fd (patch) | |
tree | eac8243b0fd8ca4c9792ad789264b871cb39324b /Lib | |
parent | 83d7dea6aa32dfbfaaf9b314b604d68b162f5676 (diff) | |
download | cpython-e0d25ce1fe1fe4379776c6bbb12981aabda865fd.zip cpython-e0d25ce1fe1fe4379776c6bbb12981aabda865fd.tar.gz cpython-e0d25ce1fe1fe4379776c6bbb12981aabda865fd.tar.bz2 |
Issue #8713: Print dangling processes/threads, if any.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/_test_multiprocessing.py | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/Lib/test/_test_multiprocessing.py b/Lib/test/_test_multiprocessing.py index f326880..cd1ed49 100644 --- a/Lib/test/_test_multiprocessing.py +++ b/Lib/test/_test_multiprocessing.py @@ -3730,9 +3730,15 @@ def install_tests_in_module_dict(remote_globs, start_method): Temp.__module__ = __module__ remote_globs[name] = Temp + dangling = [None, None] + old_start_method = [None] + def setUpModule(): multiprocessing.set_forkserver_preload(PRELOAD) - remote_globs['old_start_method'] = multiprocessing.get_start_method() + multiprocessing.process._cleanup() + dangling[0] = multiprocessing.process._dangling.copy() + dangling[1] = threading._dangling.copy() + old_start_method[0] = multiprocessing.get_start_method() try: multiprocessing.set_start_method(start_method) except ValueError: @@ -3750,9 +3756,18 @@ def install_tests_in_module_dict(remote_globs, start_method): multiprocessing.get_logger().setLevel(LOG_LEVEL) def tearDownModule(): - multiprocessing.set_start_method(remote_globs['old_start_method']) + multiprocessing.set_start_method(old_start_method[0]) # pause a bit so we don't get warning about dangling threads/processes time.sleep(0.5) + multiprocessing.process._cleanup() + gc.collect() + tmp = set(multiprocessing.process._dangling) - set(dangling[0]) + if tmp: + print('Dangling processes:', tmp, file=sys.stderr) + del tmp + tmp = set(threading._dangling) - set(dangling[1]) + if tmp: + print('Dangling threads:', tmp, file=sys.stderr) remote_globs['setUpModule'] = setUpModule remote_globs['tearDownModule'] = tearDownModule |