Conversation
Yes, definitely going to split this into a more manageable first chunk of work that can actually be considered for merging… 😅 |
yeraydiazdiaz
left a comment
There was a problem hiding this comment.
This is excellent, thanks @florimondmanca!
I left some suggestions, questions and implementation comments.
I didn't take part of the discussions leading to this PR so apologies if this was brought up before, but I feel adding built-in retries to httpx, while immediately useful, might be a source of pain for maintainers as users want more customization options, particularly when retrying and its successor tenacity offer so much in those terms. I can forsee having to push back on these or extend our implementation into a not-so-generic version of tenacity.
That's my 2c anyway, it's a really neat implementation 💯
|
@yeraydiazdiaz In my opinion, I think that httpx could provide a basic retry functionality out of the box (including respecting the As is, I still like the progress on this so far. Definitely on board with a minimal implementation, and leaving it at that. Since other retry libraries do exist, we don't have to be too comprehensive with this one, even perhaps leaving off the composition (though I think that's quite neat and I haven't seen it before). Go go @florimondmanca! 👍 |
|
Thanks for this first round of reviews! I'm preparing a PR with just the |
|
Also worth mentioning that a middleware API such as the one outlined in #783 would 100% make it possible to provide |
Is it necessary to do multiple PRs? Why not modify this one? |
|
Closing in favor of #784.
Allows keeping older PRs for future reference, and not have the cruft of comments/feedback from changes that were largely overridden. :-) |
I slept some more on #765, and I think I've come up with something quite nice.
Main changes compared to #765:
ScheduleAPI. Just abackoff_factorknow on the retries config class.RetryableErrorbase class — which of our exceptions are retryable is hard-coded in the default behavior..retry_flow()isn't really useful in itself, because extending a retry flow (even by copy-pasting our code) really isn't easy, due to many generator gotchas to watch for. So this PR implements some extension capability, mainly via theRetryLimitsinterface and being able to pass . I guess in an incremental approach we could restrict this PR toretries=<int>andretries=Retries(<int>[, backoff_factor=<float>]), and move the extension mechanism to a separate/future PR. I'm putting everything in here first to get some more feedback on the direction.Things still to do:
retries.retries.Notes to reviewers:
HTTPX_LOG_LEVEL=debug python example.pywithout starting the server, to try the behavior on connection failures.uvicorn example:appRetryOnStatusCodes.