Skip to content

fix(pool): detect dead pool threads in ProcessPool and ThreadPool - #172

Merged
noxdafox merged 1 commit into
noxdafox:mainfrom
ishantgandhi:fix/pool-loops-status
Oct 4, 2026
Merged

noxdafox merged 1 commit into
noxdafox:mainfrom
ishantgandhi:fix/pool-loops-status

Conversation

@ishantgandhi

@ishantgandhi ishantgandhi commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Part of #170.

BasePool._update_pool_status marks the pool as ERROR when one of the threads in self._loops has died. But neither ProcessPool nor ThreadPool ever set _loops, so it stayed as the empty tuple from BasePool.__init__. A dead manager thread went unnoticed and active kept returning True.

This sets _loops in _start_pool for both pools, so the status check can see their threads.

I added a test to test_thread_pool.py and test_process_pool_fork.py. Each one swaps pool_manager_loop for a function that exits right away, waits for the thread to end, and checks that active is False. Both tests fail without the fix. The full test suite and pyright pass locally.

This doesn't cover the other part of #170, where futures that were pending when the thread died stay PENDING.

@noxdafox

noxdafox commented Oct 4, 2026

Copy link
Copy Markdown
Owner

Thanks!

@noxdafox
noxdafox merged commit 2af0fe6 into noxdafox:main Oct 4, 2026
41 of 42 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants