[3.12] gh-132969: Fix exception/hang shutdown(wait=False) and a task exited abnormally#133220
[3.12] gh-132969: Fix exception/hang shutdown(wait=False) and a task exited abnormally#133220ogbiggles wants to merge 2 commits intopython:3.12from ogbiggles:3.12
Conversation
…ted abnormally 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)
|
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
|
thank you for the contribution, @ogbiggles. unfortunately, Python 3.12 is no longer accepting bug fixes, only security fixes. |
Got it, thanks. Submitted a new PR #133222 for main branch. |
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)
ProcessPoolExecutorraises exception or hangs the process whenshutdown(wait=False)and worker throws exception #132969