diff options
author | yonatanp <yonatan.perry@gmail.com> | 2023-03-16 04:44:52 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-16 04:44:52 (GMT) |
commit | 2dc94634b50f0e5e207787e5ac1d56c68b22c3ae (patch) | |
tree | 1ffdfc46379f076a08afafdb67951b992280e0b6 /Lib/concurrent/futures/process.py | |
parent | a44553ea9f7745a1119148082edb1fb0372ac0e2 (diff) | |
download | cpython-2dc94634b50f0e5e207787e5ac1d56c68b22c3ae.zip cpython-2dc94634b50f0e5e207787e5ac1d56c68b22c3ae.tar.gz cpython-2dc94634b50f0e5e207787e5ac1d56c68b22c3ae.tar.bz2 |
gh-94440: Fix issue of ProcessPoolExecutor shutdown hanging (#94468)
Fix an issue of concurrent.futures ProcessPoolExecutor shutdown hanging.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Diffstat (limited to 'Lib/concurrent/futures/process.py')
-rw-r--r-- | Lib/concurrent/futures/process.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/Lib/concurrent/futures/process.py b/Lib/concurrent/futures/process.py index 3a8637b..816edab 100644 --- a/Lib/concurrent/futures/process.py +++ b/Lib/concurrent/futures/process.py @@ -366,6 +366,11 @@ class _ExecutorManagerThread(threading.Thread): if self.is_shutting_down(): self.flag_executor_shutting_down() + # When only canceled futures remain in pending_work_items, our + # next call to wait_result_broken_or_wakeup would hang forever. + # This makes sure we have some running futures or none at all. + self.add_call_item_to_queue() + # Since no new work items can be added, it is safe to shutdown # this thread if there are no pending work items. if not self.pending_work_items: |