-
Notifications
You must be signed in to change notification settings - Fork 16
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
Adds a retry method to HttpClient #95
Conversation
The parameters for retry are modeled after httr::RETRY(), and the wait time is calculated according to the same algorithm (exponential backoff with full jitter). It also uses the same defaults.
FYI, the failure is in
Looks like open connections aren't properly cleaned up? |
FWIW, I'm getting a similar warning at the end of
Apparently, if the request doesn't complete because of things like timeout or host resolution error, an open connection may be left dangling. I think I've found where this might occur in I'm adding a fix for that, and then we'll see how that fares. FWIW, I actually cannot reproduce the error on the example code locally - perhaps in contrast to the Travis environment my local one is just not showing the dangling connections as an error at the end of the process. That said, the fix does make the dangling connections warning disappear at the end of devtools::test(). |
Codecov Report
@@ Coverage Diff @@
## master #95 +/- ##
=========================================
+ Coverage 74.28% 75.3% +1.01%
=========================================
Files 22 22
Lines 871 911 +40
=========================================
+ Hits 647 686 +39
- Misses 224 225 +1
Continue to review full report at Codecov.
|
The failure in |
I notice that the issue behind the error has been reported previously as #93. |
Thanks @hlapp for this. Been meaning to get around to it, but just haven't found the time. The connections left open I also meant to figure out, thanks for looking into that. Having a look |
closing connections isn't totally solved, but i'll try to sort it out asap. |
for these two
does it seem reasonable to open issues and handle later? or do you think they're essential for any usage? |
I don't think they're essential, and opening issues to track them for handling later would seem quite reasonable to be to have something in place that works for probably the most common use-cases. In fact, I'm not aware yet of an API that does actually give the As for enabling a client to message to the user, I did this initially in a different (non-work, JavaScript) application, and turned it off soon because it was just amounting to noise. I can, however, imagine this being somewhat useful for a client doing, for example, un-authenticated Github API requests and who then after 60 requests has to wait for almost an hour until the rate limit resets. Arguably, even then though it would be better to just get an API key and authenticate requests with it. |
I don't know how far you've gotten with this. I had another look too, and could find only two places where connections that were opened might under some circumstances end up dangling. The change I added in c159bba should close those (potential) holes. I can't test though whether these have any positive impact on the problem, because I can't reproduce what's showing on Travis, including not on a Ubuntu 16.04 machine. (The problem for running the examples doesn't even surface for |
🎉 🌮 🎉 OMG it passed!!! |
Just added that too while I was at it. Note BTW that if |
Opened an issue for the |
I hadn't worked on the connections issue yet, so thanks for that. Connections seem to be good now |
Thanks for this @hlapp - merging now |
Description
Allows retrying HTTP requests after they fail (status code >= 400). The parameters for
retry()
are modeled after httr::RETRY(), and the wait time is calculated according to the same algorithm (exponential backoff with full jitter). It also uses the same defaults.Related Issue
See ropensci/taxize#722 for context and concrete use-case.
Example
Reproduced from the documentation:
Known limitations
Retry-After
response header, if present, is assumed to be in seconds. However, the spec allows it to be an HTTP date as well.* There is no call back function for allowing a client to message to the user if and how much waiting is being applied.Addresses and closes #89.