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

Handle urllib3 timeout errors #466

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions botocore/retryhandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
from binascii import crc32

from botocore.vendored.requests import ConnectionError, Timeout
from botocore.vendored.requests.packages.urllib3.exceptions import ClosedPoolError
from botocore.vendored.requests.packages.urllib3.exceptions import \
ClosedPoolError, TimeoutError

from botocore.exceptions import ChecksumError

Expand All @@ -29,7 +30,8 @@
# to get more specific exceptions from requests we can update
# this mapping with more specific exceptions.
EXCEPTION_MAP = {
'GENERAL_CONNECTION_ERROR': [ConnectionError, ClosedPoolError, Timeout],
'GENERAL_CONNECTION_ERROR': [
ConnectionError, ClosedPoolError, Timeout, TimeoutError],
}


Expand Down
14 changes: 13 additions & 1 deletion tests/unit/test_retryhandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@

import mock
from botocore.vendored.requests import ConnectionError, Timeout
from botocore.vendored.requests.packages.urllib3.exceptions import ClosedPoolError
from botocore.vendored.requests.packages.urllib3.exceptions import \
ClosedPoolError, TimeoutError

from botocore import retryhandler
from botocore.exceptions import ChecksumError
Expand Down Expand Up @@ -222,6 +223,17 @@ def test_connection_timeouts_are_retried(self):
caught_exception=Timeout())
self.assertEqual(sleep_time, 1)

def test_response_read_timeouts_are_retried(self):
# Sometimes the connection will get a valid response
# and then later while reading the raw body it may time
# out and throw a urllib3 exception instead of a requests
# exception. We need to handle this properly.
handler = retryhandler.create_retry_handler(
self.retry_config, operation_name='OperationBar')
sleep_time = handler(response=None, attempts=1,
caught_exception=TimeoutError())
self.assertEqual(sleep_time, 1)

def test_retry_pool_closed_errors(self):
# A ClosedPoolError is retried (this is a workaround for a urllib3
# bug). Can be removed once we upgrade to requests 2.0.0.
Expand Down