Repository navigation
Don't crash the Supervisor when a worker exits during imap() - #475
LuisFigueroaG wants to merge 4 commits into
Conversation
_join_exited_workers() reads job._write_to and job._scheduled_for for every cached job that no exited worker had accepted, but IMapIterator didn't define them. A worker exiting while an imap()/imap_unordered() had tasks not yet picked up by any worker raised AttributeError in the Supervisor thread, which then called os._exit(1) and took down the whole parent process.
|
any old open issue related to this? @MehrazRumman can you try and review this? |
|
I couldn't find an open issue for this exact crash. The closest is #141 (a map/imap with a hard This PR covers the case where a worker exits for any other reason ( |
|
@GangEunzzang please have a look to this |
|
Looks good to me. The Repro with a real
The new test fails on Two things nearby that this PR doesn't cover (both also happen on
Up to you whether |
If a worker exits while an
imap()/imap_unordered()still has tasks that no worker has picked up,_join_exited_workers()readsjob._write_to/job._scheduled_foron theIMapIterator, which doesn't define them. The Supervisor thread crashes withAttributeError: 'IMapIterator' object has no attribute '_write_to', andPoolThread.runthen callsos._exit(1), so the whole parent process goes down. One way to hit it:Pool(1), anapply_asyncwhose task raisesSystemExit, and animap()queued behind it.This adds both attributes to
IMapIteratorasNoneclass attributes, asApplyResultalready has them. It only adds the missing defaults, so existing behaviour and the public API don't change.Added a unit test that calls
_join_exited_workers()directly on a pool without threads, so a failure shows up as a normal test failure instead of killing the test process.