]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-132969: Fix error/hang when shutdown(wait=False) and task exited abnormally ...
authorAjay Kamdar <140011370+ogbiggles@users.noreply.github.com>
Tue, 10 Jun 2025 11:28:31 +0000 (07:28 -0400)
committerGitHub <noreply@github.com>
Tue, 10 Jun 2025 11:28:31 +0000 (13:28 +0200)
commit598aa7cc98bc1b39f10ec41decddd8dd88799fe1
tree64c64f7b544f09810f7ef61baaff85b885a1ad56
parentee7345d507884aaaa000e51858c64852ac4f6d02
gh-132969:  Fix error/hang when shutdown(wait=False) and task exited abnormally (GH-133222)

When shutdown is called with wait=False, the executor thread keeps running
even after the ProcessPoolExecutor's state is reset. The executor then tries
to replenish the worker processes pool resulting in an error and a potential hang
when it comes across a worker that has died. Fixed the issue by having
_adjust_process_count() return without doing anything if the ProcessPoolExecutor's
state has been reset.

Added unit tests to validate two scenarios:
max_workers < num_tasks (exception)
max_workers > num_tasks (exception + hang)
Lib/concurrent/futures/process.py
Lib/test/test_concurrent_futures/test_shutdown.py
Misc/NEWS.d/next/Library/2025-04-30-19-32-18.gh-issue-132969.EagQ3G.rst [new file with mode: 0644]