File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed
Lib/test/test_concurrent_futures Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change 11import multiprocessing
22import os
33import queue
4+ import signal
45import sys
56import threading
67import time
@@ -238,7 +239,15 @@ def test_process_pool_executor_terminate_kill_workers(self):
238239 # We should get started, but not finished since we'll terminate the workers just after
239240 self .assertEqual (q .get (timeout = 1 ), 'started' )
240241
242+ worker_process = list (executor ._processes .values ())[0 ]
241243 getattr (executor , function_name )()
244+ worker_process .join ()
245+
246+ if function_name == 'terminate_workers' or sys .platform == 'win32' :
247+ # On windows, kill and terminate both send SIGTERM
248+ self .assertEqual (worker_process .exitcode , - signal .SIGTERM )
249+ elif function_name == 'kill_workers' :
250+ self .assertEqual (worker_process .exitcode , - signal .SIGKILL )
242251
243252 self .assertRaises (queue .Empty , q .get , timeout = 1 )
244253
@@ -256,7 +265,6 @@ def test_process_pool_executor_terminate_kill_workers_not_started_yet(self):
256265
257266 context_with_mocked_process = multiprocessing .get_context ()
258267 with unittest .mock .patch .object (context_with_mocked_process , 'Process' ) as mock_process :
259-
260268 with futures .ProcessPoolExecutor (max_workers = 1 , mp_context = context_with_mocked_process ) as executor :
261269 # The worker has not been started yet, terminate/kill_workers should basically no-op
262270 getattr (executor , function_name )()
You can’t perform that action at this time.
0 commit comments