fix: auto-reconnect not triggered on multi-block read path - #787
Open
gijzelaerr wants to merge 2 commits into
Open
fix: auto-reconnect not triggered on multi-block read path#787gijzelaerr wants to merge 2 commits into
gijzelaerr wants to merge 2 commits into
Conversation
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>
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.
Summary
_execute_packets_sequentialnow uses_send_receive_with_reconnect()instead of_send_receive(), so multi-block reads trigger auto-reconnect on connection loss_execute_packets_parallelcatches connection errors and falls back to sequential reconnect-aware execution after re-establishing the connectionRoot 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
pytest tests/)auto_reconnect=True, read 15+ tags viaread_tags(), drop PLC connection, confirm reconnect firesCloses #785
🤖 Generated with Claude Code