Repository navigation
Conversation
Enter exponential cooldown immediately on unparsable 429 responses instead of firing a 5s blind retry, prevent concurrent in-flight 429s or 5xx/405 retries from bypassing blocks or double-escalating streak, preserve streak when an in-flight 200 OK completes during an active block, expose retry_after on ConnectionException, and propagate ConnectionException through connect()/async_connect().
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.
Follow-up to #200 based on live
0.19.21testing on a GALEVO heat pump (hpSys: true) and designed to pair cleanly withfustom/ariston-remotethermo-home-assistant-v3#558.Problem
Observed in live Home Assistant logs on
ariston==0.19.21/ integrationv0.20.13:429 Requests are blockedwithout a duration orRetry-Afterheader, the first hit slept 5 s and fired a blind retry that consistently hit429again before entering cooldown.galevo_device.async_update_state()(asyncio.gather) hitting bare429within milliseconds both escalated_rate_limit_streakin a single poll cycle (e.g.streak 2→streak 3175 ms apart), and a 5xx/405 retry (is_retry=True) could bypass an active 429 block window.ConnectionExceptiondid not exposeretry_after, andconnect()/async_connect()wrappedConnectionExceptioninto an empty exception, hiding the 429 status and remaining delay from callers like HA PR #558.Changes
429responses (no"blocked for N seconds"and noRetry-After) enter the exponential cooldown (60 s→600 s) immediately instead of sleeping 5 s and retrying blindly. Parsed429durations keep the existing sleep-and-retry-once behaviour.429responses arriving while a block window is already active (now < _blocked_until) or a retry is in flight do not escalate_rate_limit_streakagain.rate_limit_retryfromis_retryso 5xx/405 retries respect an active 429 block window instead of bypassing it._rate_limit_streakoncetime.time() >= _blocked_until, so a concurrent200 OKfinishing during an active block cannot wipe out the streak.ConnectionException.retry_after& login propagation:retry_after: Optional[float] = NonetoConnectionException(preserving existingargsuntouched) and populated it on all 429 exceptions.connect()andasync_connect()re-raiseConnectionExceptiondirectly so callers receive the 429 status andretry_after.Tests
python -m coverage run --source=ariston -m unittest discover --start-directory tests→ 126 passed (99% total coverage).retry_afterexposure (short-circuit, repeated 429, andconnect()/async_connect()), and streak preservation when an in-flight200 OKlands during an active block.