zulip: Optionally retry requests that hit RATE_LIMIT_HIT. - #924
Open
devnishantt wants to merge 1 commit into
Open
devnishantt wants to merge 1 commit into
devnishantt wants to merge 1 commit into
Conversation
HTTP 429 currently bubbles up to every application. Tim asked for this as an opt-in Client option so callers that cannot block keep the old behavior. When auto_retry_rate_limits=True, do_api_query sleeps for the server's retry-after (JSON field, then Retry-After header) plus a small jitter, then retries, up to 10 times. The cap and jitter avoid pinning a client to the server's allowed rate. Fixes zulip#773. Signed-off-by: Nishant <nishanttgithub@gmail.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.
HTTP 429 currently bubbles up to every application. Tim asked for this
as an opt-in Client option so callers that cannot block keep the old
behavior.
When
auto_retry_rate_limits=True,do_api_querysleeps for theserver's retry-after (JSON field, then Retry-After header) plus a small
jitter, then retries, up to 10 times. The cap and jitter avoid pinning
a client to the server's allowed rate.
Default is
False.Fixes #773.
Previous #908 implemented a simpler version of this and was closed
unreviewed.
How did you test this PR?
Unit tests in
zulip/tests/test_rate_limit.py(7 passed): default off,JSON retry-after, Retry-After header fallback, jitter, 10-retry cap.
Self-review checklist
(variable names, code reuse, readability, etc.).
Communicate decisions, questions, and potential concerns.
Individual commits are ready for review (see commit discipline).
Completed manual review and testing of the following: