-
Notifications
You must be signed in to change notification settings - Fork 570
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
Handle backoff on HTTP 503 error when pushing repeatedly #1038
Conversation
The documentation is not available anymore as the PR was closed or merged. |
Codecov Report
@@ Coverage Diff @@
## main #1038 +/- ##
==========================================
+ Coverage 83.01% 83.20% +0.18%
==========================================
Files 36 37 +1
Lines 3822 3846 +24
==========================================
+ Hits 3173 3200 +27
+ Misses 649 646 -3
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for tackling this!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice addition, thank you!
Thanks @SBrandeis and @merveenoyan for the review ! I'm merging once CI is happy :) |
Fix #1027.
This PR adds a separate helper to perform HTTP requests with a backoff strategy. Retries can be made on specific exceptions or specific status codes. By default, we mainly target Connection timeout and HTTP 503 Service Unavailable. It is a slight variation of the existing backoff implementation in
_request_wrapper
but separated so that we can unit tests and document it properly.This PR adds backoff usage by default when pushing a LFS file to the Hub, which is the initial purpose of #1027. At the moment sleep times will increase as such: 1s, 2s, 4s, 8s, 8s, 8s...
I did not add the helper in the documentation since I'm not exactly sure yet if that's something we want to do at the moment. I think other HTTP-related helpers will come as user-agent handler (#1018) so maybe we can update documentation at that time. Docstring for
http_backoff
is already ready.(for the record the excellent backoff package exists but is not used here to avoid an extra external dependency)