Skip to content

Commit d5f7578

Browse files
committed
Add constants for terminate/kill methods
1 parent 7f09586 commit d5f7578

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

Lib/test/test_concurrent_futures/test_process_pool.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,15 @@ def __init__(self, mgr):
2626
def __del__(self):
2727
self.event.set()
2828

29+
TERMINATE_WORKERS = futures.ProcessPoolExecutor.terminate_workers.__name__
30+
KILL_WORKERS = futures.ProcessPoolExecutor.kill_workers.__name__
2931
FORCE_SHUTDOWN_PARAMS = [
30-
dict(function_name='terminate_workers'),
31-
dict(function_name='kill_workers'),
32+
dict(function_name=TERMINATE_WORKERS),
33+
dict(function_name=KILL_WORKERS),
3234
]
3335

3436
def _put_sleep_put(queue):
35-
""" Used as part of test_process_pool_executor_terminate_workers """
37+
""" Used as part of test_terminate_workers """
3638
queue.put('started')
3739
time.sleep(2)
3840
queue.put('finished')
@@ -269,12 +271,14 @@ def test_force_shutdown_workers(self, function_name):
269271
getattr(executor, function_name)()
270272
worker_process.join()
271273

272-
if function_name == 'terminate_workers' or \
274+
if function_name == TERMINATE_WORKERS or \
273275
sys.platform == 'win32':
274276
# On windows, kill and terminate both send SIGTERM
275277
self.assertEqual(worker_process.exitcode, -signal.SIGTERM)
276-
elif function_name == 'kill_workers':
278+
elif function_name == KILL_WORKERS:
277279
self.assertEqual(worker_process.exitcode, -signal.SIGKILL)
280+
else:
281+
self.fail(f"Unknown operation: {function_name}")
278282

279283
self.assertRaises(queue.Empty, q.get, timeout=1)
280284

0 commit comments

Comments
 (0)