Wire rate limiter into Frigidaire via requests.Session#55
Merged
Conversation
The autowrap monkey-patched self._session.request, but Frigidaire never created a _session — it called module-level requests.get/post/put. The AttributeError was swallowed by a bare except, so the limiter, 429/Retry-After handling, and default timeout silently did nothing in production since #45 was merged. Inline the limiter setup into __init__: create a requests.Session, wrap its request method before authenticate() runs (so auth is throttled too), route all HTTP calls through self._session, and promote the rate-limit knobs to explicit kwargs. Drop rl_autowrap.py. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Owner
Author
|
@karlg100 heads-up — the autowrap added in #45 has been silently disabled in production since it merged. The This PR wires the limiter in for real. Tagging you in case you want to verify against your 4-AC scene setup once it lands; that was the canonical reproduction. |
- Widen timeout type to float | None to match docstring - Remove dead self.timeout (no longer read after the Session refactor) - Drop redundant `or RL_DEFAULT_METHODS` fallback at the call site by letting wrap_session_request handle None internally - Collapse kwargs.update(overrides) into a single dict expression in conftest - Drop misleading "connect,read" tuple-string support from smoke test (the previous ternary silently fell back to 15.0 on tuple input) Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
# Conflicts: # frigidaire/__init__.py
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
The autowrap added in #45 silently disabled itself. It patched
self._session.request, butFrigidairenever created_session— HTTP went through module-levelrequests.get/post/put. TheAttributeErrorwas swallowed by a bareexcept, so write spacing, 429/Retry-Afterhandling, and the default timeout have all been no-ops in production. Downstreamcas_3403lockouts that #45 was meant to prevent (bm1549/home-assistant-frigidaire#91) were never actually mitigated by 0.1.3+.This PR inlines the limiter setup into
Frigidaire.__init__: create arequests.Session, wraprequestbeforeauthenticate()runs (so the auth flow is throttled too — the original incident was an auth storm), and route every HTTP call throughself._session. The magic kwargs become explicit, typed, kw-only constructor params.rl_autowrap.pyis deleted.A regression test (
test_writes_are_rate_limited_through_session) asserts the wrapper actually fires on a realexecute_actioncall, so this can't silently break again.Test plan
pytest— 74 passed in 0.15sruff check .— cleanmypy frigidaire/— cleancas_3403🤖 Generated with Claude Code