fix: Recover from Sphinx parallel workers dying without a result - #362
Open
hoxbro wants to merge 1 commit into
Open
fix: Recover from Sphinx parallel workers dying without a result#362hoxbro wants to merge 1 commit into
hoxbro wants to merge 1 commit into
Conversation
The previous attempt (257b95a) read the task function back from `proc._args`, but `multiprocessing.BaseProcess.start` deletes `_target`, `_args` and `_kwargs` to avoid a refcycle, so recovery raised `AttributeError: 'ForkProcess' object has no attribute '_args'` on every started worker. Record the task function at submit time instead, and handle the EOFError at `pipe.recv()` where the failing task id is known, re-running that chunk in the main process. Assisted-by: Claude Code:claude-opus-5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Follow-up to #357, which did not work — the recovery path itself crashed:
AI Summary of what went wrong:
multiprocessing.BaseProcess.start()runsdel self._target, self._args, self._kwargsto avoid a refcycle (bpo-30775), soproc._argsis gone on exactly the processes the recovery targeted — every started worker. The build then died on anAttributeErrorinstead of the originalEOFError.The fix takes a different approach, in a new
nbsite/_parallel.py:ParallelTasks.__init__/add_taskare patched to record the task function per task id at submit time. Sphinx keeps no reference to it anywhere, which is why fix: Improve EOF Error seen in HoloViews #357 tried to read it back off the deadProcess._join_oneis reimplemented rather than wrapped, so theEOFErroris handled at thepipe.recv()that raises it, where the failing task id is known. Wrapping the whole call loses that, and identifying the dead pipe afterwards meansrecv()-ing on live pipes and discarding real results.ParallelTasks._process's exception handling so a genuine task failure still surfaces asSphinxParallelErrorrather than being swallowed._result_funcs,_args,_precvs,_pworking) follows the untouched path, so waiting workers still get started andjoin()terminates. fix: Improve EOF Error seen in HoloViews #357 returnedTruewithout touching state, which could also spin.Note this makes the build complete by retrying the chunk in-process. If the worker died from something deterministic in that chunk (e.g. a segfaulting C extension rather than an OOM kill) the main process will hit it too — but it will fail with a real traceback instead of a bare
EOFError. The HoloViews symptom looks like resource pressure, so a retry should generally succeed.Testing
nbsite/tests/test_parallel.pyuses a task that callsos._exit(1)only whenmultiprocessing.parent_process() is not None, so it kills the worker but returns a distinguishable value when re-run in the main process. Covers: recovery of the dead worker's task, sibling tasks still completing, normal result collection, and a genuinely failing task still raisingSphinxParallelError.All 4 tests fail on
main, and the pre-fixAttributeErrorabove reproduces locally againstmainwith the same scenario. Full suite: 52 passed.AI Disclosure
Tool & Model: Claude Code + Opus 5
Usage: Diagnosed why #357 failed, wrote
nbsite/_parallel.pyandnbsite/tests/test_parallel.py.Checklist