Repository navigation
fix: make GokartBuildError picklable - #702
Merged
Merged
Conversation
Exception.__reduce__ rebuilds an exception as cls(*self.args), and GokartBuildError only puts the message in args, so unpickling failed with a TypeError on the required raised_exceptions. A GokartBuildError raised in a multiprocessing / ProcessPoolExecutor worker then broke the pool instead of reaching the parent. Closes #701 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CdA6RRuAhGPHPwCmTEgJGv
kitagry
marked this pull request as ready for review
November 23, 2026 13:57
kitagry
requested review from
Hi-king,
hiro-o918,
hirosassa,
mamo3gr,
mski-iksm,
ujiuji1259 and
yokomotod
as code owners
November 23, 2026 13:57
This was referenced Nov 23, 2026
hirosassa
approved these changes
Nov 23, 2026
hirosassa
left a comment
Collaborator
There was a problem hiding this comment.
LGTM. __reduce__ rebuilds with (message, raised_exceptions) and restores __dict__, so attributes such as status from #684 survive without further changes. Both tests cover the reported failure (round trip and a ProcessPoolExecutor worker).
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.
Closes #701
What
GokartBuildErrorcould not be pickled.Exception.__reduce__rebuilds an exception ascls(*self.args), andself.argsis only(message,), so unpickling failed withTypeError: ... missing 1 required positional argument: 'raised_exceptions'. AGokartBuildErrorraised in aProcessPoolExecutorworker broke the pool (BrokenProcessPool). In amultiprocessing.Poolworker, the pool's result-handler thread died andget()without a timeout waited forever.This PR adds
GokartBuildError.__reduce__, which rebuilds the error with(message, raised_exceptions)and restores the instance__dict__as the state.str(e)ande.argsdon't change.__dict__. This includesstatusfrom fix!: raise GokartBuildError for MISSING_EXT and NOT_RUN in gokart.build #684, so__reduce__does not need to change when fix!: raise GokartBuildError for MISSING_EXT and NOT_RUN in gokart.build #684 is merged. I checked this on the fix!: raise GokartBuildError for MISSING_EXT and NOT_RUN in gokart.build #684 branch.Tests
test_pickle_round_trip_keeps_message_and_attributes: the message,args,raised_exceptionsand an extra attribute survivepickle.loads(pickle.dumps(e)).test_error_raised_in_child_process_reaches_parent: aGokartBuildErrorraised in aProcessPoolExecutorworker (spawn) reaches the parent as aGokartBuildError.Both fail on master and pass with this change.
Relation to #684
#684 also changes the
GokartBuildErrorclass body: it addsstatus=to__init__and a line afterself.raised_exceptions = .... I built this PR on master rather than on #684, for these reasons:statusis carried by__dict__, so this fix works with or without fix!: raise GokartBuildError for MISSING_EXT and NOT_RUN in gokart.build #684.Not in this PR
GokartBuildErrorstill fails, becauseraised_exceptionsholds that exception. This is a separate design question: replacing such exceptions with a stand-in would lose their type.raised_exceptionsa default value instead, which would make the built-in reduce work. I chose not to, because it changes the public signature and makesraised_exceptionslook optional.🤖 Generated with Claude Code
https://claude.ai/code/session_01CdA6RRuAhGPHPwCmTEgJGv