Skip to content

Fix multi-printer retry CPU loops - #16

Merged
cjavad merged 1 commit into
mainfrom
fix/connection-retry-cpu
Sep 17, 2026
Merged

cjavad merged 1 commit into
mainfrom
fix/connection-retry-cpu

Conversation

@cjavad

@cjavad cjavad commented Sep 17, 2026

Copy link
Copy Markdown
Member

The multi-printer connection loop can consume a CPU core during shutdown. asyncio.CancelledError was treated as a reconnectable network error, so cancellation was swallowed. Once the event loop's DNS executor shut down, every reconnect raised RuntimeError, logged a full traceback, and retried immediately.

This change exits and cleans up on cancellation, routes unexpected connection failures through the existing reconnect backoff, and honors Retry-After: Ns from failed add_connection responses. A server response such as Retry-After: 249s now delays the next add attempt for 249 seconds instead of using an unrelated local exponential delay.

Validation:

  • pytest -q tests/test_connection_retry.py tests/test_multi_printer_retry.py tests/test_connection_manager.py (7 passed)
  • Remaining suite excluding live test_client_app.py: 84 passed; three environment failures require writes outside the workspace or network-interface access.
  • Live strace before mitigation measured about 72 traceback cycles per second on each wedged worker.

@cjavad
cjavad force-pushed the fix/connection-retry-cpu branch from a5fe975 to 952f0dc Compare September 17, 2026 12:07
@cjavad
cjavad force-pushed the fix/connection-retry-cpu branch from 952f0dc to c47680e Compare September 17, 2026 12:22
@cjavad
cjavad marked this pull request as ready for review September 17, 2026 12:33
@cjavad
cjavad merged commit fa84bb0 into main Sep 17, 2026
9 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