Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): Proper retry count in KazooRetry #748

Merged
merged 2 commits into from
Jul 15, 2024

Conversation

ceache
Copy link
Contributor

@ceache ceache commented Mar 11, 2024

Make sure the number of attempts matches the max_retry parameter. Add unit tests to that effect.

Why is this needed?

So that users can precisely control the number of retries

Proposed Changes

  • Move the location of the attempt increase to before the check against max_try so we don't end up calling max_tries + 1 times the function.

Does this PR introduce any breaking change?

No, it shouldn't.

Copy link

codecov bot commented Mar 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.67%. Comparing base (73309b2) to head (86e69f2).
Report is 4 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #748      +/-   ##
==========================================
- Coverage   97.01%   96.67%   -0.34%     
==========================================
  Files          27       27              
  Lines        3549     3553       +4     
==========================================
- Hits         3443     3435       -8     
- Misses        106      118      +12     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

kazoo/tests/test_retry.py Show resolved Hide resolved
kazoo/retry.py Show resolved Hide resolved
@@ -133,10 +133,10 @@ def __call__(self, func, *args, **kwargs):
except ConnectionClosedError:
raise
except self.retry_exceptions:
self._attempts += 1
# Note: max_tries == -1 means infinite tries.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you see a way to test this case?

Copy link
Contributor Author

@ceache ceache Mar 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure what you mean: what 'case'?
Do you mean that it on catches the exception if it is in the self.retry_exceptions set?

Copy link
Member

@StephenSorriaux StephenSorriaux Apr 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking of the note Note: max_tries == -1 means infinite tries.

Make sure the number of attempts matches the `max_retry` parameter.
Add unit tests to that effect.
@ceache ceache enabled auto-merge July 15, 2024 15:35
@ceache ceache merged commit c5ab988 into python-zk:master Jul 15, 2024
3 checks passed
@ceache ceache deleted the fix/retry branch July 15, 2024 15:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants