Add option to hook into internal pycyphal errors#377
Merged
pavel-kirienko merged 4 commits intoOpenCyphal:masterfrom Mar 25, 2026
Merged
Add option to hook into internal pycyphal errors#377pavel-kirienko merged 4 commits intoOpenCyphal:masterfrom
pavel-kirienko merged 4 commits intoOpenCyphal:masterfrom
Conversation
pavel-kirienko
requested changes
Mar 25, 2026
Member
pavel-kirienko
left a comment
There was a problem hiding this comment.
Thanks! The idea is sound. I left a few remarks.
The patch version should be bumped for us to merge this; see CONTRIBUTING.md.
14ec3cb to
f581802
Compare
Contributor
Author
|
Updated - thanks for quick review 👍 |
3562fe1 to
3577b7e
Compare
3577b7e to
9a2ec4b
Compare
9a2ec4b to
e583471
Compare
pavel-kirienko
approved these changes
Mar 25, 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.
Currently, when pycyphal encounters an error in one of its background asyncio tasks (e.g. a task receiving messages in the background), it simply calls logger.exception. This is fine for debugging with a human looking at the logs, but insufficient for production environments where you need to react to unexpected problems — there is no way of knowing an exception happened except by reading the logs.
This PR introduces set_internal_error_handler, which can be used to register a global hook into pycyphal. This hook will receive all background exceptions when they happen and can react to them as needed (e.g. by raising a fatal error). When no hook is registered, the behavior is unchanged — exceptions are simply logged.