Skip to content

Commit d756264

Browse files
committed
Set max_workers to 3 in test_cancel_futures
1 parent bf75a3e commit d756264

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Lib/test/test_concurrent_futures.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -343,14 +343,14 @@ def test_hang_issue12364(self):
343343
f.result()
344344

345345
def test_cancel_futures(self):
346-
executor = self.executor_type()
346+
executor = self.executor_type(max_workers=3)
347347
fs = [executor.submit(time.sleep, .1) for _ in range(50)]
348348
executor.shutdown(cancel_futures=True)
349349
# 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.
352352
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)=}")
354354

355355
# Ensure the other futures were able to finish.
356356
# Use "not fut.cancelled()" instead of "fut.done()" to include futures

0 commit comments

Comments
 (0)