File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed
Lib/test/test_concurrent_futures Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -33,10 +33,12 @@ def __del__(self):
33
33
dict (function_name = KILL_WORKERS ),
34
34
]
35
35
36
- def _put_sleep_put (queue ):
36
+ def _put_wait_put (queue , event ):
37
37
""" Used as part of test_terminate_workers """
38
38
queue .put ('started' )
39
- time .sleep (2 )
39
+ event .wait ()
40
+
41
+ # We should never get here since the event will not get set
40
42
queue .put ('finished' )
41
43
42
44
@@ -261,12 +263,13 @@ def test_force_shutdown_workers_invalid_op(self):
261
263
def test_force_shutdown_workers (self , function_name ):
262
264
manager = self .get_context ().Manager ()
263
265
q = manager .Queue ()
266
+ e = manager .Event ()
264
267
265
268
with self .executor_type (max_workers = 1 ) as executor :
266
- executor .submit (_put_sleep_put , q )
269
+ executor .submit (_put_wait_put , q , e )
267
270
268
271
# 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.
270
273
self .assertEqual (q .get (timeout = support .SHORT_TIMEOUT ), 'started' )
271
274
272
275
worker_process = list (executor ._processes .values ())[0 ]
You can’t perform that action at this time.
0 commit comments