Repository navigation
Store failures raised as BaseException subclasses with the JSON serializer - #10672
Merged
auvipy merged 2 commits intoSep 19, 2026
Merged
Conversation
…lizer encode_result() only ran prepare_exception() for Exception instances, so a task failing with a bare BaseException or asyncio.CancelledError reached the JSON encoder as the raw object and mark_as_failure() died with EncodeError. No result was ever written and callers waited for their own timeout. Pickle was unaffected because it can serialize the object as is. Prepare any BaseException the same way; exception_to_python() already accepts them on the way back.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #10672 +/- ##
=======================================
Coverage 89.14% 89.14%
=======================================
Files 153 153
Lines 20284 20284
Branches 2403 2403
=======================================
Hits 18082 18082
Misses 1897 1897
Partials 305 305
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
auvipy
self-requested a review
September 19, 2026 06:59
auvipy
reviewed
Sep 19, 2026
auvipy
approved these changes
Sep 19, 2026
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.
Backend.encode_result()only runsprepare_exception()when the result is anException, so a task that fails with a bareBaseExceptionorasyncio.CancelledErrorreaches the JSON encoder as the raw object andmark_as_failure()dies withEncodeError: Object of type BaseException is not JSON serializable. No result is written and the caller waits for its own timeout. Pickle is unaffected since it serializes the object as is.This came up while looking at Billiard 4.3.0 in #10659: the worker loop now reports any
BaseExceptiona task raises instead of turning it intoWorkerLostError.SystemExitandKeyboardInterruptare handled in #10667; this covers the rest.Checking
BaseExceptioninstead is enough,exception_to_python()already accepts them on the way back. With a prefork worker against Redis, both cases now come back as the raised exception in well under a second where they used to time out.