fix(diagnostics): stop CEC probe from dumping cores on Pi 5#2957
Merged
Conversation
The get_display_power celery-beat task (every 5 min) runs the CEC
probe as a `python -c` subprocess. On boards without a usable CEC
adapter (e.g. Raspberry Pi 5) libcec's adapter thread aborts during
interpreter teardown ("FATAL: exception not rethrown", SIGABRT),
dumping a ~38 MB core each run that eventually fills the disk and
crash-loops celery. The script's try/except can't catch it — it's a
C++/pthread teardown abort, not a Python exception.
- Write the result, flush stdout, then os._exit(0) to skip the
Python/libcec teardown that aborts.
- Apply to both _CEC_QUERY_SCRIPT and _CEC_SET_SCRIPT.
Verified on a live Pi 5: 3 task runs produce no cores, value still
reported as "Unknown".
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
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.



Issues Fixed
Not tied to a tracked issue. On Raspberry Pi 5 (and any board without a usable CEC adapter), the celery container would slowly fill the SD card with core dumps and eventually crash-loop once the disk hit 100%.
Description
The
get_display_powercelery-beat task (every 5 min) runs the CEC probe as apython -csubprocess (_CEC_QUERY_SCRIPTinsrc/anthias_server/lib/diagnostics.py). On a Pi 5 there's no usable CEC adapter, socec.init()succeeds buttv.is_on()raisesIOError→ the probe reportsUnknown. Then, during interpreter teardown, libcec's adapter thread aborts (FATAL: exception not rethrown, SIGABRT), dumping a ~38 MB core every run. The script'stry/exceptcan't catch it because it's a C++/pthread teardown abort, not a Python exception.Fix: once the answer is on stdout,
flush()andos._exit(0)to skip the Python/libcec teardown that aborts. Applied to both_CEC_QUERY_SCRIPTand_CEC_SET_SCRIPT. The reported value is unchanged — the probe already has its answer before teardown.Verified on a live Pi 5: dispatching the task 3× through the worker produces no cores (previously one per run) and still reports
Unknown.ruff check/ruff format --checkclean; all 36test_diagnostics.pytests pass.Checklist
🤖 Generated with Claude Code