Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4edea15

Browse files
committed
More PR feedback
1 parent e48e0ea commit 4edea15

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

Lib/test/test_concurrent_futures/test_process_pool.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,12 @@ def __del__(self):
3333
dict(function_name=KILL_WORKERS),
3434
]
3535

36-
def _put_sleep_put(queue):
36+
def _put_wait_put(queue, event):
3737
""" Used as part of test_terminate_workers """
3838
queue.put('started')
39-
time.sleep(2)
39+
event.wait()
40+
41+
# We should never get here since the event will not get set
4042
queue.put('finished')
4143

4244

@@ -261,12 +263,13 @@ def test_force_shutdown_workers_invalid_op(self):
261263
def test_force_shutdown_workers(self, function_name):
262264
manager = self.get_context().Manager()
263265
q = manager.Queue()
266+
e = manager.Event()
264267

265268
with self.executor_type(max_workers=1) as executor:
266-
executor.submit(_put_sleep_put, q)
269+
executor.submit(_put_wait_put, q, e)
267270

268271
# We should get started, but not finished since we'll terminate the
269-
# workers just after
272+
# workers just after and never set the event.
270273
self.assertEqual(q.get(timeout=support.SHORT_TIMEOUT), 'started')
271274

272275
worker_process = list(executor._processes.values())[0]

0 commit comments

Comments
 (0)