]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
[3.14] gh-132969: Fix error/hang when shutdown(wait=False) and task exited abnormall...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Fri, 13 Jun 2025 13:49:54 +0000 (15:49 +0200)
committerGitHub <noreply@github.com>
Fri, 13 Jun 2025 13:49:54 +0000 (15:49 +0200)
commit6754a507c5079aed78b1480cf7d3897db277ba5a
tree1f51f8fe6b880c5850a11408755b00225721cea0
parent8a78ee6d8d4f2de4cda425e498082bdcd343e87f
[3.14] gh-132969:  Fix error/hang when shutdown(wait=False) and task exited abnormally (GH-133222) (GH-135344)

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)
(cherry picked from commit 598aa7cc98bc1b39f10ec41decddd8dd88799fe1)

Co-authored-by: Ajay Kamdar <140011370+ogbiggles@users.noreply.github.com>
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]