question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

No Retry in HTTPResponse.read() method.

See original GitHub issue

It appears that the retry support in urllib3 doesn’t cover the HTTPResponse.read() method. This means that if you pass preload_content=False to urlopen() as requests does, that any errors that occur while read()ing the body will not automatically be retried. Doing this transparently would be difficult to do since urllib3 doesn’t know what the calling library has done with the parts of the body it’s already received.

What would be nice though is to provide the Retry() object on the response object and provide instructions for how the caller of the library can use it to implement retries themselves. Perhaps this could look something like:

response = pool.urlopen(...)
while not response.closed and not response.retries.is_exhausted():
    try:
        data = []
        data.append(response.read(4096))
    except response.retries.exceptions as exc:
        # This would raise an error if there are no more retries
        response = response.retry()

Thoughts?

Issue Analytics

  • State:open
  • Created 9 years ago
  • Comments:11 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
Lukasacommented, Nov 14, 2016

Nope

0reactions
gaborbernatcommented, Nov 14, 2016

any progress on this?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Is there any possibility to retry only Python low-level urllib3 ...
The server side is external, aka non-manageable by me, only the client side. I see no any possible way to have retry on...
Read more >
Response and Decoders - urllib3 1.26.13 documentation
Unread data in the HTTPResponse connection blocks the connection from being released back to the pool. Returns underlying file descriptor if one exists....
Read more >
http.client — HTTP protocol client — Python 3.11.1 ...
getresponse() when the attempt to read the response results in no data read from the connection, indicating that the remote end has closed...
Read more >
Status codes in HTTP - W3C
Server has received the request but there is no information to send back, and the client should stay in the same document view....
Read more >
common - Go Documentation Server
Request, details ClientCallDetails) (response *http.Response, err error) · func ... provider do not return an error, this method will not check AuthType(), ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found