Skip to content

Commit 89c355a

Browse files
committed
Try to fix transiency of test_force_shutdown_workers
On some platforms we seem to get 255 instead of -SIGNAL, so instead use mocks to know we called the correct method
1 parent b3c18bf commit 89c355a

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

Lib/test/test_concurrent_futures/test_process_pool.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -270,15 +270,18 @@ def test_force_shutdown_workers(self, function_name):
270270
self.assertEqual(q.get(timeout=5), 'started')
271271

272272
worker_process = list(executor._processes.values())[0]
273+
274+
Mock = unittest.mock.Mock
275+
worker_process.terminate = Mock(wraps=worker_process.terminate)
276+
worker_process.kill = Mock(wraps=worker_process.kill)
277+
273278
getattr(executor, function_name)()
274279
worker_process.join()
275280

276-
if function_name == TERMINATE_WORKERS or \
277-
sys.platform == 'win32':
278-
# On windows, kill and terminate both send SIGTERM
279-
self.assertEqual(worker_process.exitcode, -signal.SIGTERM)
281+
if function_name == TERMINATE_WORKERS:
282+
worker_process.terminate.assert_called()
280283
elif function_name == KILL_WORKERS:
281-
self.assertEqual(worker_process.exitcode, -signal.SIGKILL)
284+
worker_process.kill.assert_called()
282285
else:
283286
self.fail(f"Unknown operation: {function_name}")
284287

0 commit comments

Comments
 (0)