Repository navigation
Stop calling the cloud while it rate limits - #6
Merged
Merged
Conversation
On HTTP 429 the cloud blocks the account for some seconds ("Requests
are blocked for 66 seconds"). The integration shares one AristonAPI
between its coordinators and actions, and the others kept sending
requests inside the block. Each API object now remembers the block
(from the answer, else 60 s) and raises ConnectionException(429, ...)
without a request until it ends. args[0] stays 429, so callers still
see a rate limit. The async path now gives the 429 body as str too.
Only 5xx answers are retried once after 5 s. A 4xx (wrong value,
refused login) gets the same answer again, so a retry only doubled
the requests and the wait.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
wojciech-aniol
marked this pull request as ready for review
October 25, 2026 08:58
Review fixes. Two requests at once can both get a 429; the second one, with a shorter or unknown time, no longer ends the block early. A 429 answer without "blocked for N seconds" is logged as a warning, since nobody has seen the real text yet. The regex and the default are private, so they do not become public names. New tests cover a login inside the block and a 5xx retry that works. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review fixes. The integration builds a new AristonAPI on each setup retry, reload and config or reauth flow, so a block kept in one object was lost exactly when requests come in bursts. The block now lives in the module, per API URL and login: new objects of the same account see it, other accounts do not. A 408 means "send it again", like a 5xx. Without the retry a short 408 on a new login made the integration ask for the password again. Co-Authored-By: Claude Opus 5.5 <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.
After an HTTP 429 the cloud blocks the account for some seconds, but other users of the same
AristonAPI(the integration's coordinators and actions) kept sending requests inside the block. The block is now kept per account (API URL and login), so every API object of that account raisesConnectionException(429, "blocked locally for N s")without a request until it ends. Also, only 5xx and 408 are retried once; other 4xx are raised at once instead of being sent twice.Changes
_blocked_until(time.monotonic), keyed by API URL and login: a newAristonAPIof the same account (setup retry, reload, config or reauth flow) sees the block, other accounts do not. A 429 sets it from the body ("blocked for N seconds", any case), else 60 s and a warning with the body. A later, shorter 429 does not end the block early.args[0]stays429, so the integration'sclassify_errorstill sees a rate limit. A login inside the block raisesConnectionException()from that error, as before.Noneand 429 without retry stay. Other 4xx (400, 401, 403…) raiseConnectionException(status)at once.str, like the sync path.fustom/python-ariston-api#187: sleeping the block time inside the request, a block shared by all accounts, its R2 login and enum changes.Tests
tests/test_ariston_api.pywith a fake cloud and clock (no network), sync and async: body parsing, 60 s default and its warning, no request inside the block, request after it, block per account, two 429s at once, login inside the block, 4xx not retried, 5xx and 408 retried once.main21 of the 29 new tests fail. The 8 retry cases (5xx, 408) pass there on purpose: they guard the retry that stays.ariston-netat 634efac) passes all 597 tests with this library onPYTHONPATH,tests/test_requests.pycounts included, so its bump PR should pass without changes.Not checked
The 429 body text comes only from
fustom/python-ariston-api#187; nobody here saw a real one. If it does not match, the block is 60 s.🤖 Generated with Claude Code