File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -343,14 +343,14 @@ def test_hang_issue12364(self):
343
343
f .result ()
344
344
345
345
def test_cancel_futures (self ):
346
- executor = self .executor_type ()
346
+ executor = self .executor_type (max_workers = 3 )
347
347
fs = [executor .submit (time .sleep , .1 ) for _ in range (50 )]
348
348
executor .shutdown (cancel_futures = True )
349
349
# We can't guarantee the exact number of cancellations, but we can
350
- # guarantee that *some* were cancelled. In this case, at least half
351
- # should have been cancelled.
350
+ # guarantee that *some* were cancelled. With setting max_workers to 3,
351
+ # most of the submitted futures should have been cancelled.
352
352
cancelled = [fut for fut in fs if fut .cancelled ()]
353
- self .assertTrue (len (cancelled ) >= 25 , msg = f"{ len (cancelled )= } " )
353
+ self .assertTrue (len (cancelled ) >= 35 , msg = f"{ len (cancelled )= } " )
354
354
355
355
# Ensure the other futures were able to finish.
356
356
# Use "not fut.cancelled()" instead of "fut.done()" to include futures
You can’t perform that action at this time.
0 commit comments