Repository navigation
fix: allow a minimum retry wait of 0 ms - #332
Merged
Merged
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
|
Caution Review failedThe pull request is closed.
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. |
Contributor
Author
|
@SoulPancake could you take a look when you have a moment? thx |
Codecov Report✅ All modified and coverable lines are covered by tests. ❌ Your project status has failed because the head coverage (70.00%) is below the target coverage (80.00%). You can increase the head coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #332 +/- ##
==========================================
+ Coverage 69.99% 70.00% +0.01%
==========================================
Files 142 142
Lines 10774 10780 +6
==========================================
+ Hits 7541 7547 +6
Misses 3233 3233 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.