Conversation
Owner
|
Thanks! Bit busy now but I'll get to testing this next week. |
Added async-lru and tenacity requirements
Contributor
Author
👍 Forgot to update the requirements and requirements_dev to add the new dependencies. Hopefully mypy will pass now. |
Update is_rate_limit_error function to match what tenacity expects. Address mypy error: Argument 1 to "retry_if_exception" has incompatible type "Callable[[RpcError], bool]"; expected "Callable[[BaseException], bool]" [arg-type]
nshp
reviewed
Oct 7, 2025
|
|
||
| return response | ||
|
|
||
| def is_rate_limit_error(exception: RpcError) -> bool: |
Owner
There was a problem hiding this comment.
This type also needs to change now to BaseException, then we should be good :)
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.
Proposed change to solve the RESOURCE_EXHAUSTED errors caused by API rate-limiting.
Retry with Exponential Backoff: The core API call (fetch_vehicles) in python-lucidmotors will now automatically retry upon receiving a rate-limit error from the server, waiting for an increasing amount of time between attempts. (Implemented with tenacity).
Asynchronous Caching: The fetch_vehicles method is now cached for 15 seconds. This prevents multiple, redundant API calls from being made in quick succession (e.g., during Home Assistant startup or dashboard refreshes), reducing the load on the Lucid API. (Implemented with async-lru).