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
urllib3 Retry and Response Hooks (Duplicates #4514) #4747
Comments
Can anyone suggest a work around for this? (except for the standard flagging and re-doing what Retry does) |
@belthaZornv can you share what part of our documentation misled you here?
|
@sigmavirus24 I'm not saying you or the documentation misled me or someone else, but otherwise I'm more interested in discussing what you'd expect, would you expect the response hook to execute? (Taking into consideration that not everyone knows requests inside out) I did, I expected the hook to execute at least once; but I might have been wrong in thinking so, so my question is, what is the ideal solution when someone wants to Retry but also wants a response hook to execute? More over I believe that unless urllib3 honours the hooks than there isn't much to add. Although for someone new to requests, one would expect hooks and auth classes to run as by default even in Retry, after knowing the structure beneath it all, yes, I fully agree it shouldn't or even can't.. but people are and will get lost over this.. and would be nice to find the ideal solution if any exist. |
Just got bitten by the same thing myself too. I was assuming hooks would work, until I dug deeper. |
For anyone here getting stuck on this, reread the reply from sigmavirus24. If your use case was like mine ( a reauth hook ) if the status code 401 or 403 is in your status_forcelist urllib3 will gobble the response that you may be trying to hook on. You may only want to retry on < 403 ...Seems so obvious now. |
Given you have a session, and have successfully attached the auth class and the response hooks accordingly; although you'd like to add the Retry class into the picture from urllib3.
Expected Result
I'd expect the response hooks to be honoured - at the very least on the first response (not retry).
Actual Result
The response hooks are ignored completely.
Reproduction Steps
System Information
The text was updated successfully, but these errors were encountered: