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

Add RetryBackoff to support custom @retry backoff strategies #247

Merged
merged 14 commits into from
Jan 6, 2022

Conversation

prkumar
Copy link
Owner

@prkumar prkumar commented Jan 5, 2022

Add a new base class, uplink.retry.RetryBackoff, which can be extended to implement custom backoff strategies. Subclasses can override three methods:

  • get_timeout_after_response(request, response): Returns the number of seconds to wait before retrying the request, or None to indicate that the given response should be returned.
  • get_timeout_after_exception(request, exc_type, exc_val, exc_tb): Returns the number of seconds to wait before retrying the request, or None to indicate that the given exception should be raised.
  • handle_after_final_retry(): Handles any clean-up necessary following the final retry attempt.

An instance of a RetryBackoff subclass can be provided through the backoff argument of the @retry decorator.

#238

@codecov
Copy link

codecov bot commented Jan 5, 2022

Codecov Report

Merging #247 (dee8883) into master (fc21923) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master      #247   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           44        44           
  Lines         2410      2466   +56     
  Branches       342       355   +13     
=========================================
+ Hits          2410      2466   +56     
Impacted Files Coverage Δ
uplink/arguments.py 100.00% <100.00%> (ø)
uplink/auth.py 100.00% <100.00%> (ø)
uplink/commands.py 100.00% <100.00%> (ø)
uplink/compat.py 100.00% <100.00%> (ø)
uplink/converters/__init__.py 100.00% <100.00%> (ø)
uplink/converters/typing_.py 100.00% <100.00%> (ø)
uplink/decorators.py 100.00% <100.00%> (ø)
uplink/retry/__init__.py 100.00% <100.00%> (ø)
uplink/retry/backoff.py 100.00% <100.00%> (ø)
uplink/retry/retry.py 100.00% <100.00%> (ø)
... and 7 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e2f8225...dee8883. Read the comment docs.

@mivade
Copy link

mivade commented Jan 5, 2022

Thanks!

@prkumar prkumar merged commit 7eebaf1 into master Jan 6, 2022
@prkumar prkumar deleted the custom-retry-backoff branch January 6, 2022 22:54
@mivade
Copy link

mivade commented Jan 7, 2022

@prkumar I really appreciate your quick work on this!

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.

None yet

2 participants