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.

urllib3.exceptions.ProtocolError not catched, even with retry=adaptive

See original GitHub issue

[Not a contribution]

From time to time, when downloading large files, the download is aborted with:

Traceback (most recent call last):
     ...
     File ".../python3.7/site-packages/boto3/s3/inject.py", line 172, in download_file
       extra_args=ExtraArgs, callback=Callback)
     File ".../python3.7/site-packages/boto3/s3/transfer.py", line 307, in download_file
       future.result()
     File ".../python3.7/site-packages/s3transfer/futures.py", line 106, in result
       return self._coordinator.result()
     File ".../python3.7/site-packages/s3transfer/futures.py", line 265, in result
       raise self._exception
     File ".../python3.7/site-packages/s3transfer/tasks.py", line 126, in __call__
       return self._execute_main(kwargs)
     File ".../python3.7/site-packages/s3transfer/tasks.py", line 150, in _execute_main
       return_value = self._main(**kwargs)
     File ".../python3.7/site-packages/s3transfer/download.py", line 521, in _main
       for chunk in chunks:
     File ".../python3.7/site-packages/s3transfer/download.py", line 649, in __next__
       chunk = self._body.read(self._chunksize)
     File ".../python3.7/site-packages/s3transfer/utils.py", line 570, in read
       value = self._stream.read(*args, **kwargs)
     File ".../python3.7/site-packages/botocore/response.py", line 77, in read
       chunk = self._raw_stream.read(amt)
     File ".../python3.7/site-packages/urllib3/response.py", line 540, in read
       raise IncompleteRead(self._fp_bytes_read, self.length_remaining)
     File ".../python3.7/contextlib.py", line 130, in __exit__
       self.gen.throw(type, value, traceback)
     File ".../python3.7/site-packages/urllib3/response.py", line 454, in _error_catcher
       raise ProtocolError("Connection broken: %r" % e, e)
   urllib3.exceptions.ProtocolError: ("Connection broken: ConnectionResetError(54, 'Connection reset by peer')", ConnectionResetError(54, 'Connection reset by peer'))

even though adaptive retry mode is enabled.

I can see the debug messages: standard - Not retrying request., but no message like standard - Max attempts of 4 reached. which I usually see when downloading files and for example the internet connection drops.

It seems that this code path (an exception in self._raw_stream.read(amt) in __next__ in for chunk in chunks: in s3transfer.download.GetObjectTask._main) doesn’t do any exception handling, as opposed to an exception occurring in s3transfer.download.GetObjectTask._main earlier on during response = client.get_object, which handles exceptions down in the stack in botocore.endpoint.Endpoint._send_request.

Is this on purpose, or can/should this exception also be retried?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
nateprewittcommented, Dec 10, 2021

Hi @jwmx, I’ve added boto/botocore#2573 with a preliminary proposal to start handling this with a BotoCoreError subclassed error. You should be able to track progress on this there.

0reactions
github-actions[bot]commented, Dec 11, 2021

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to use the urllib3.exceptions.ProtocolError function ... - Snyk
Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues...
Read more >
Exceptions - urllib3 1.26.13 documentation
Raised when a socket timeout error occurs. Catching this error will catch both ReadTimeoutErrors and ConnectTimeoutErrors . exception ...
Read more >
Cannot catch requests.exceptions.ConnectionError with try ...
If I understand that traceback correctly, the error is not thrown in my code, and therefore I am not able to catch it?...
Read more >
try...catch - JavaScript - MDN Web Docs - Mozilla
If an exception is thrown from the try block, even when there's no catch block to handle the exception, the finally block still...
Read more >
HandlingExceptions - Python Wiki
Sometimes, you want to catch all errors that could possibly be generated, ... For general (non-Python specific) ideas about exceptions, ...
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