File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -39,6 +39,25 @@ def __init__(self):
3939 self ._lock = threading .Lock ()
4040 self ._preload_modules = ['__main__' ]
4141
42+ def _stop (self ):
43+ # Method used by unit tests to stop the server
44+ with self ._lock :
45+ self ._stop_unlocked ()
46+
47+ def _stop_unlocked (self ):
48+ if self ._forkserver_pid is None :
49+ return
50+
51+ # close the "alive" file descriptor asks the server to stop
52+ os .close (self ._forkserver_alive_fd )
53+ self ._forkserver_alive_fd = None
54+
55+ os .waitpid (self ._forkserver_pid , 0 )
56+ self ._forkserver_pid = None
57+
58+ os .unlink (self ._forkserver_address )
59+ self ._forkserver_address = None
60+
4261 def set_forkserver_preload (self , modules_names ):
4362 '''Set list of module names to try to load in forkserver process.'''
4463 if not all (type (mod ) is str for mod in self ._preload_modules ):
Original file line number Diff line number Diff line change @@ -5650,7 +5650,13 @@ def tearDownModule():
56505650 # Sleep 500 ms to give time to child processes to complete.
56515651 if need_sleep :
56525652 time .sleep (0.5 )
5653+
56535654 multiprocessing .process ._cleanup ()
5655+
5656+ # Stop the ForkServer process if it's running
5657+ from multiprocessing import forkserver
5658+ forkserver ._forkserver ._stop ()
5659+
56545660 # bpo-37421: Explicitly call _run_finalizers() to remove immediately
56555661 # temporary directories created by multiprocessing.util.get_temp_dir().
56565662 multiprocessing .util ._run_finalizers ()
Original file line number Diff line number Diff line change 1+ multiprocessing tests now stop the ForkServer instance if it's running: close
2+ the "alive" file descriptor to ask the server to stop and then remove its UNIX
3+ address.
You can’t perform that action at this time.
0 commit comments