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

Why retry doesn't work on sesson.post method #2975

Closed
demonguy opened this issue Jan 21, 2016 · 7 comments
Closed

Why retry doesn't work on sesson.post method #2975

demonguy opened this issue Jan 21, 2016 · 7 comments

Comments

@demonguy
Copy link

I've pasted requests.packages.urllib3.util.Retry object to max_retries argument of HTTPAdapter
But i found, it only works on session.get. How could i make it work on session.post ?

@Lukasa
Copy link
Member

Lukasa commented Jan 21, 2016

When you say it doesn't work on post, what does that mean? What are you expecting to see and what actually happens?

@demonguy
Copy link
Author

it means. when i use session.post to access url = 'https://httpbin.org/status/500', it doesn't retry and just return an 500 error, not maxretry error.

@Lukasa
Copy link
Member

Lukasa commented Jan 21, 2016

@demonguy That's not how retries work by default. Generally speaking, retries only affect actual connection issues that prevent us from sending the request or retrieving the response altogether. Normally, we do not issue retries on 500 errors. You can change that behaviour by initializing your Retry object with status_forcelist=range(500, 600), as documented on the Retry object API document.

@Lukasa Lukasa closed this as completed Jan 21, 2016
@demonguy
Copy link
Author

I am doing what you said, did you read my original post? i past "requests.packages.urllib3.util.Retry" object.

And of course i passed status_forcelist, but it only works on get, not on post

@Lukasa
Copy link
Member

Lukasa commented Jan 21, 2016

If you look at the API documentation, you'll notice that it says this:

method_whitelist (iterable) –
Set of uppercased HTTP method verbs that we should retry on.
By default, we only retry on methods which are considered to be indempotent (multiple requests with the same parameters end with the same state).

POST is not considered IDEMPOTENT. You'll need to extend the method whitelist with POST to allow max_retries to function there.

@sigmavirus24
Copy link
Contributor

@demonguy in the future questions are to be asked on StackOverflow. Please do not ask a question in an issue again.

@demonguy
Copy link
Author

Sorry. I search for the whole Request document, i should expect it's in urllib3 documents.
Really sorry.
And i did search Google and stackoverflow, maybe i use wrong keyword so i didn't get answer from that.
Sorry

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants