Repository navigation
Do not resend reboot or speed test after a dropped connection - #555
Open
manueltarouca wants to merge 1 commit into
Open
manueltarouca wants to merge 1 commit into
manueltarouca wants to merge 1 commit into
Conversation
The transport retry in __post resent every request up to five times on ServerDisconnectedError/ClientOSError. For a reboot the router drops the connection because it accepted the request, so one reboot() call reached the router five times. Non-idempotent actions now only retry when the connection could not be opened (ClientConnectorError).
iMicknl
reviewed
Oct 22, 2026
Comment on lines
+220
to
+225
| @backoff.on_exception( | ||
| backoff.expo, | ||
| ClientConnectorError, | ||
| max_tries=5, | ||
| ) | ||
| async def __post_once(self, url, data): |
Owner
There was a problem hiding this comment.
Should the on exception not be moved to the __send? It seems like it is now added to the wrong function?
Author
There was a problem hiding this comment.
It's intentional. __send does the request and has no retry. The two wrappers add different retry rules:
__post: retries on any connection error, same as before. Used by everything else (login, get, set, logout).__post_once: retries only onClientConnectorError, i.e. the request never left the client. Used byrebootandrun_speed_test.
If the ClientConnectorError retry moved to __send, __post would retry it a second time (ClientConnectorError is a subclass of ClientOSError), so a connect failure could take up to 25 attempts.
I can add a short comment above __send if that helps, or restructure it if you prefer a different split.
This branch has not been deployed
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
reboot()can reboot the router up to 5 times. Same forrun_speed_test().Problem
__postretries every request up to 5 times onServerDisconnectedError/ClientOSError.A router that accepts a reboot drops the connection without replying. The client sees a
disconnect and sends the reboot again.
Reproduced with a local server that counts requests and drops each connection:
one
reboot()call → 5 reboot requests received.Fix
reboot()andrun_speed_test()retry only when the connection could not be opened(
ClientConnectorError). The request never left the client, so a retry is safe.Trade-off: if a pooled keep-alive connection was closed by the router just before
reboot(),the call now raises
ConnectionErrorinstead of retrying. Callers usuallylogin()rightbefore
reboot(), so the connection is fresh.Not changed:
login()still uses the retrying path. A replayed login can use up routersessions (
XMO_MAX_SESSION_COUNT_ERR). Happy to look at that in a separate PR.Tests
tests/unit/test_request_retries.py, using a local TCP server that reads the request, then drops the connection:reboot/run_speed_test: sent once, thenConnectionError. Fails onmain(sent 5 times).get_value_by_xpath: still retried after a disconnect.