Skip to content

Add option to hook into internal pycyphal errors#377

Merged
pavel-kirienko merged 4 commits intoOpenCyphal:masterfrom
LukasLendvorsky:error_reporting_pr
Mar 25, 2026
Merged

Add option to hook into internal pycyphal errors#377
pavel-kirienko merged 4 commits intoOpenCyphal:masterfrom
LukasLendvorsky:error_reporting_pr

Conversation

@LukasLendvorsky
Copy link
Copy Markdown
Contributor

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.

Copy link
Copy Markdown
Member

@pavel-kirienko pavel-kirienko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! The idea is sound. I left a few remarks.

The patch version should be bumped for us to merge this; see CONTRIBUTING.md.

@LukasLendvorsky
Copy link
Copy Markdown
Contributor Author

Updated - thanks for quick review 👍

@LukasLendvorsky LukasLendvorsky force-pushed the error_reporting_pr branch 2 times, most recently from 3562fe1 to 3577b7e Compare March 25, 2026 14:31
@coveralls
Copy link
Copy Markdown

coveralls commented Mar 25, 2026

Coverage Status

coverage: 93.394% (-0.01%) from 93.408%
when pulling e0963d2 on LukasLendvorsky:error_reporting_pr
into 58c356e on OpenCyphal:master.

@pavel-kirienko pavel-kirienko merged commit 7b00386 into OpenCyphal:master Mar 25, 2026
7 checks passed
@LukasLendvorsky LukasLendvorsky deleted the error_reporting_pr branch March 26, 2026 13:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants