You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
class ChunkedEncodingError(RequestException):
"""The server declared chunked encoding but sent an invalid chunk."""
While this true it's highly confusing. What actually happens is that the server did not respond in time so the connection was closed. The solution is to retry the code and attempt again:
def get(tries=5):
for n in range(tries):
try:
GET call
return whatever
except ChunkedEncodingError as e:
if n == tries - 1:
raise e
This has been asked many time over the internet including even here: #4484
I recommend adding an optional argument for the GET call which will specify the tries number and that will be handled by the get call itself. This will avoid this problem and allow the user more control.
meaning that the GET will return the exception only when the max retries has been reached.
If my suggestion is not accepted at least edit the docs and suggest the template of the solution to avoid the problem.
The text was updated successfully, but these errors were encountered:
Hi @ron819, while the exception we're wrapping isn't the clearest, it does convey the connection has been broken with the server. The cause of that could be a multitude of things, but is likely the server forcing the connection closed.
I don't think it's clear that most users would want to retry in the case of a misbehaving server. Our API for Requests is currently frozen, so changes to the get method are unlikely unless there's significant oversight in functionality. Your example shows this should be easily implementable in 10-15 lines of code in your application, giving your complete control over how it will work. For those reasons, I don't think we'll be adding anything new to the Requests code base at this time.
The docs says about
ChunkedEncodingError
:While this true it's highly confusing. What actually happens is that the server did not respond in time so the connection was closed. The solution is to retry the code and attempt again:
This has been asked many time over the internet including even here: #4484
I recommend adding an optional argument for the
GET
call which will specify the tries number and that will be handled by the get call itself. This will avoid this problem and allow the user more control.meaning that the GET will return the exception only when the max retries has been reached.
If my suggestion is not accepted at least edit the docs and suggest the template of the solution to avoid the problem.
The text was updated successfully, but these errors were encountered: