-
Notifications
You must be signed in to change notification settings - Fork 441
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
Implement retry mechanism when using requests #466
Conversation
@brandur-stripe Making a stab at retry issue that I created. Let me know if there is anything else you'd like to see here. |
@jonathan-s Nice — thank you for the contribution! I'm going to have someone else on the team take an initial review pass first, then we'll see what we can do to get this merged in. |
Thanks a lot!
On Tue 21. Aug 2018 at 19:46, Brandur ***@***.***> wrote:
@jonathan-s <https://github.com/jonathan-s> Nice — thank you for the
contribution! I'm going to have someone else on the team take an initial
review pass first, then we'll see what we can do to get this merged in.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#466 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ACBsEtQTX47K0ZlA9Xu1wFDDdS84UP5qks5uTEeQgaJpZM4WEvAo>
.
--
Sent from Gmail Mobile
|
Hi Jonathan! Thank you for your time and this PR :) To protect against creating unintended duplicate requests given automatic retries, the client should create idempotency key, if not given by the caller, following our docs[0]. The implementation on retry seems great with the standard My concern of going ahead with using -cc @brandur-stripe for more thoughts if we should go ahead with [0] Idempotency [1] Ruby sleep implementation [2] Go sleep implementation |
@mickjermsurawong-stripe Thanks for the reply. I hear you regarding the idempotency key. Right now it looks like it's an optional requirement which you can supply for each api method. I wonder, is there a case when you would want to NOT send an idempotency key? If there is no such case, perhaps it would be worth centralizing that at one place and let the client take care of generating an idempotency key? With regards to avoiding step-wise locking. I think this could be worth to raise an issue upstream in urllib3. |
Also out of curiosity. What % usage is there of the other clients other than requests. Since you have the user-agent it would be possible to find out :) |
Hi @johnathan-s, Idempotency key is not needed for If I understand your suggestion about centralization of idempotency setting correctly, yup! we can supply the idempotency key in the header Hmm I don't think the specific underlying client is exposed outside the Meanwhile, it would be great to have tests on the added features, idempotency key and the retries. One needs to install https://github.com/stripe/stripe-mock to run our pytests. |
Hi @jonathan-s I had a discussion with others, and it seems like the randomness is something we would like to have still. And making PR to urllib3 as you suggest would still run into the same problem of having the change only on people who use With that, I have a more concrete follow-up on my earlier proposal on how to implement this at the abstract class in the
I'm happy to take on this PR as well, if what I communicate isn't very clear or you are not convinced that the effort here is worthwhile. Or please let me know what arrangement works best for you to move this forward! |
Hi @jonathan-s , |
[Referring to above to retroactively register response to issue] |
Hi,
Currently I'm on holiday for the coming week or so. So I won't be able to
pursue this PR right now, so if somebody wants to finish this as soon as
possible feel free to start! If nobody has started by the time I'm back
again I'll take a look at it.
Cheers
*Jonathan Sundqvist*
Twitter <http://www.twitter.com/argparse> | Linkedin
<http://se.linkedin.com/in/jonathansundqvist>
…On Tue, Aug 28, 2018 at 9:42 PM, mickjermsurawong-stripe < ***@***.***> wrote:
[Referring to above to retroactively register response to issue]
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#466 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ACBsEvCyl4WbkKnvQ3mLJctbQTaY01mgks5uVZ00gaJpZM4WEvAo>
.
|
Thanks for the note! Will find some time to get to this :) |
@jonathan-s, I'll close this now due to the #470 |
Thanks!
On Fri 7. Sep 2018 at 23:09, mickjermsurawong-stripe < ***@***.***> wrote:
Closed #466 <#466>.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#466 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ACBsErHRTDzyyNq4DT8HpWfS6alSnlamks5uYuBqgaJpZM4WEvAo>
.
--
Sent from Gmail Mobile
|
This PR implements a retry mechanism if any request would fail when using requests. It closes #464.
More detailed documentation of
Retry
can be found in the urllib3 documentation{backoff factor} * (2 ^ ({number of total retries} - 1))
between retries