fix!: honor explicit exit codes and control-flow signals in Actor exit#1048
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1048 +/- ##
==========================================
- Coverage 91.75% 91.71% -0.05%
==========================================
Files 50 50
Lines 3215 3222 +7
==========================================
+ Hits 2950 2955 +5
- Misses 265 267 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Pijukatel
approved these changes
Jul 15, 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.
Previously
Actor.__aexit__treated anyBaseExceptionas "the user function threw": it logged"Actor failed with an exception"and forced the exit code to91(EXIT_CODE_ERROR_USER_FUNCTION_THREW), ignoring any explicitly-requested exit code and mishandling control-flow signals.Consequences:
Actor.fail(exit_code=42, exception=e)silently exited91, contradicting thefail()docstring and the error-handling guide example (which mapsValueError→10).sys.exit(5)inside the Actor block exited91instead of5.KeyboardInterrupt(Ctrl+C) became a logged failure + exit91instead of interrupt semantics.asyncio.CancelledErrorwas consumed bysys.exit(91), breaking the cancellation contract.Now
__aexit__dispatches on the exception type:Exceptionstill falls back to91, but only when no exit code was set explicitly (sofail(exit_code=X, exception=e)honorsX);SystemExitkeeps its own code;BaseException(Ctrl+C, task cancellation, ...) is re-raised untouched after cleanup.Added regression tests covering all four cases.
BREAKING CHANGE: Actor exit codes and failure logging are now accurate to the exception type.
fail(exception=e)exits with the requestedexit_code(default1) instead of always91;sys.exit(n)inside the Actor block exitsninstead of91;KeyboardInterruptandasyncio.CancelledErrorpropagate instead of becoming a logged failure with exit91; and"Actor failed with an exception"is no longer logged for those control-flow cases.