mirror of
https://github.com/python/cpython.git
synced 2025-08-22 17:55:18 +00:00
bpo-38546: multiprocessing tests stop the resource tracker (GH-17641)
Multiprocessing and concurrent.futures tests now stop the resource tracker process when tests complete. Add ResourceTracker._stop() method to multiprocessing.resource_tracker. Add _cleanup_tests() helper function to multiprocessing.util: share code between multiprocessing and concurrent.futures tests.
This commit is contained in:
parent
630c8df5cf
commit
9707e8e22d
5 changed files with 42 additions and 21 deletions
|
@ -439,3 +439,28 @@ def close_fds(*fds):
|
|||
"""Close each file descriptor given as an argument"""
|
||||
for fd in fds:
|
||||
os.close(fd)
|
||||
|
||||
|
||||
def _cleanup_tests():
|
||||
"""Cleanup multiprocessing resources when multiprocessing tests
|
||||
completed."""
|
||||
|
||||
from test import support
|
||||
|
||||
# cleanup multiprocessing
|
||||
process._cleanup()
|
||||
|
||||
# Stop the ForkServer process if it's running
|
||||
from multiprocessing import forkserver
|
||||
forkserver._forkserver._stop()
|
||||
|
||||
# Stop the ResourceTracker process if it's running
|
||||
from multiprocessing import resource_tracker
|
||||
resource_tracker._resource_tracker._stop()
|
||||
|
||||
# bpo-37421: Explicitly call _run_finalizers() to remove immediately
|
||||
# temporary directories created by multiprocessing.util.get_temp_dir().
|
||||
_run_finalizers()
|
||||
support.gc_collect()
|
||||
|
||||
support.reap_children()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue