Skip to content

Commit 32cfb29

Browse files
committed
Address reviewer feedback
1 parent f10dbb9 commit 32cfb29

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

Lib/concurrent/futures/process.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,7 @@ def flag_executor_shutting_down(self):
519519
new_pending_work_items = {}
520520
for work_id, work_item in self.pending_work_items.items():
521521
if work_item.future.cancel():
522+
# gh-136655: ensure cancelled futures are notified
522523
work_item.future.set_running_or_notify_cancel()
523524
else:
524525
new_pending_work_items[work_id] = work_item

Lib/test/test_concurrent_futures/executor.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,16 @@ def __len__(self):
3939
return 0
4040

4141

42+
class CancelNotifyTestException(Exception):
43+
pass
44+
45+
46+
def blocking_raiser(barrier=None):
47+
if barrier is not None:
48+
barrier.wait()
49+
raise CancelNotifyTestException()
50+
51+
4252
class ExecutorTest:
4353

4454
# Executor.shutdown() and context manager usage is tested by
@@ -250,6 +260,7 @@ def test_swallows_falsey_exceptions(self):
250260

251261
@warnings_helper.ignore_fork_in_thread_deprecation_warnings()
252262
def test_shutdown_notifies_cancelled_futures(self):
263+
self.assertGreater(self.worker_count, 1)
253264

254265
# TODO: remove when gh-109934 is fixed
255266
if self.executor_type is futures.ThreadPoolExecutor:
@@ -271,12 +282,7 @@ def test_shutdown_notifies_cancelled_futures(self):
271282

272283
for future in fs:
273284
self.assertRaises(
274-
(FalseyBoolException, futures.CancelledError, threading.BrokenBarrierError),
285+
(CancelNotifyTestException, futures.CancelledError, threading.BrokenBarrierError),
275286
future.result)
276287

277288
self.assertIn('CANCELLED_AND_NOTIFIED', [f._state for f in fs])
278-
279-
def blocking_raiser(barrier=None):
280-
if barrier is not None:
281-
barrier.wait()
282-
raise FalseyBoolException()

0 commit comments

Comments
 (0)