Skip to content

fix: auto-reconnect not triggered on multi-block read path - #787

Open
gijzelaerr wants to merge 2 commits into
masterfrom
fix/785-reconnect-multi-block
Open

fix: auto-reconnect not triggered on multi-block read path#787
gijzelaerr wants to merge 2 commits into
masterfrom
fix/785-reconnect-multi-block

Conversation

@gijzelaerr

Copy link
Copy Markdown
Owner

Summary

  • _execute_packets_sequential now uses _send_receive_with_reconnect() instead of _send_receive(), so multi-block reads trigger auto-reconnect on connection loss
  • _execute_packets_parallel catches connection errors and falls back to sequential reconnect-aware execution after re-establishing the connection

Root cause

When read_tags() batched many variables into multi-block packets, the optimized execution path bypassed _send_receive_with_reconnect(). Auto-reconnect only worked for the single-block path (few tags), silently failing for multi-block reads (many tags in production).

Test plan

  • Verify existing tests pass (pytest tests/)
  • Verify mypy, ruff, and pre-commit all pass
  • Manual test: connect with auto_reconnect=True, read 15+ tags via read_tags(), drop PLC connection, confirm reconnect fires

Closes #785

🤖 Generated with Claude Code

When read_tags() batched multiple variables into multi-block packets,
the optimized execution path (_execute_packets_sequential and
_execute_packets_parallel) called _send_receive() directly, bypassing
_send_receive_with_reconnect(). This meant auto_reconnect only worked
for the single-block path (few tags) but silently failed for multi-block
reads (many tags in production).

Fix _execute_packets_sequential to rebuild requests via
_send_receive_with_reconnect so sequence counters are refreshed after
reconnection. Wrap _execute_packets_parallel with reconnect logic that
falls back to sequential execution after re-establishing the connection.

Closes #785

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Adds test_reconnect_on_multi_block_read that exercises the
_execute_packets_sequential reconnect wrapper with 20 INT tags,
fixing coverage below the 75% threshold.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

python-snap7掉线重连失效

1 participant