Repository navigation
Conversation
Requests were sent without a timeout, so a connection that stops responding blocked update_data() forever. Apply a default (10, 30) s timeout through a Session subclass and lower urllib3 retries from 20 to 5 so a hung request fails within minutes.
This was referenced Oct 2, 2026
Open
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.
No request passes
timeout=, so a request that connects and then stops responding blocks forever. In Home Assistant this freezes polling:update_data()never returns, the coordinator never schedules the next refresh, and entities keep their last values until the integration is reloaded. See klejejs/ha-thermia-heat-pump-integration#147 (also #118 and #126 there).Changes:
ThermiaSession, arequests.Sessionsubclass that appliesDEFAULT_REQUEST_TIMEOUT = (10, 30)(connect, read, in seconds) to every request unless the caller passes its owntimeout. This covers all current call sites and any new ones.Retry(total=20)is nowRetry(total=5). urllib3 also retries GET read timeouts, so with 20 retries one hung request could still block for about 32 minutes (21 attempts of 30 s plus backoff). With 5 the worst case is about 3 minutes. POSTs (login, register writes) are retried only on connection failures, where the server never received the request, and never on read timeouts or 5xx responses. So a write is never sent twice.Trade-off: a network outage while logging in now fails after a few seconds of retries. Before, it kept retrying for up to about 21 minutes. klejejs/ha-thermia-heat-pump-integration#153 makes Home Assistant retry the setup in that case.
Test:
setup_thermia_and_perform_basic_testsnow asserts that every request carries the default timeout. Before this change, all 16 requests in each model test hadtimeout=None.Also checked locally against a socket that accepts connections and never answers, with the timeout shortened to 1 s: the old session was still blocked after 15 s, and the new one raised after 9 s (6 attempts plus 3 s backoff). A live login and poll against the Thermia API (iTec IQ) still work.
Related: #61 also adds a timeout, but it also retries non-idempotent requests (the login POST, the auth-code exchange and register writes) and makes
__set_register_valueraise on non-200 responses. This PR is only the timeout and retry-count change. Both edit the same lines inThermiaAPI.__init__, so only one of them can be merged as is.