Skip to content

Guard serial read against pyserial blocking indefinitely#45

Merged
widgetii merged 1 commit intomasterfrom
fix/serial-read-timeout-guard
Apr 19, 2026
Merged

Guard serial read against pyserial blocking indefinitely#45
widgetii merged 1 commit intomasterfrom
fix/serial-read-timeout-guard

Conversation

@widgetii
Copy link
Copy Markdown
Member

Summary

  • Wrap run_in_executor(pyserial.read) with asyncio.wait_for so if pyserial blocks despite its timeout (e.g. device reboots mid-transfer), the protocol fails cleanly instead of hanging forever.
  • Guard timeout is 2 * pyserial_timeout + 1s — only fires when pyserial itself is stuck.

Previously, if a device rebooted during SPL transfer, defib would hang indefinitely waiting for an ACK that would never come.

Test plan

  • uv run pytest tests/ -x -v --ignore=tests/fuzz — 326 passed
  • Full install on hi3516av300 hardware — normal operation unaffected (26s burn, full TFTP flash)

🤖 Generated with Claude Code

Wrap run_in_executor with asyncio.wait_for so that if pyserial's
read() blocks despite the timeout (e.g. device reboots mid-transfer),
the protocol fails cleanly instead of hanging forever.

The guard timeout is 2x the pyserial timeout + 1s, so it only fires
when pyserial itself is stuck.

Tested on hi3516av300 hardware — no interference with normal operation.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@widgetii widgetii merged commit 769b082 into master Apr 19, 2026
13 checks passed
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.

1 participant