Repository navigation
Conversation
random_time() and jitter() pick the wait with random.randrange(minimum, maximum), which raises ValueError on an empty range. With min_wait_in_ms set to 0 both bounds are 0, so the first retry crashed instead of retrying immediately. Return the minimum when the range is empty. Signed-off-by: Srinivas Chippagiri <cvas22@gmail.com>
Contributor
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 59 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
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.
Description
With
retry_params.min_wait_in_ms = 0, the first retry crashes:random_time()(inapi_client.pyandsync/api_client.py) andjitter()(inoauth2_common.py) compute the wait asrandom.randrange(minimum, maximum)with bounds of2**n * min_wait_in_msand2**(n+1) * min_wait_in_ms. Whenmin_wait_in_msis 0, both bounds are 0 andrandrangeraises. So a configuration asking to retry without waiting fails with an unrelated error instead. I hit this while writing the tests for #331.Change: when the range is empty, the helpers return the minimum (0 s here) instead of calling
randrange. Nothing changes for a positivemin_wait_in_ms.Testing
New
test/backoff_test.py:random_time(async and sync) andjitterreturn 0 with a minimum wait of 0. These fail onmainwith the error above.random_timestays within[2**n * min, 2**(n+1) * min)for a positive minimum.pytest testpasses locally: 529 passed, 12 skipped.ruff checkis clean on the new test file.