Skip to content

Commit

Permalink
Retry connection timeouts
Browse files Browse the repository at this point in the history
Now that we've set a connection timeout, we need to retry
these just like a generic ConectionError from requests.
  • Loading branch information
jamesls committed Jul 18, 2014
1 parent 1197efe commit 892be1f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
4 changes: 2 additions & 2 deletions botocore/retryhandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import logging
from binascii import crc32

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

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


Expand Down
11 changes: 10 additions & 1 deletion tests/unit/test_retryhandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from tests import unittest

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

from botocore import retryhandler
Expand Down Expand Up @@ -213,6 +213,15 @@ def test_create_retry_handler_with_socket_errors(self):
sleep_time = handler(response=None, attempts=1,
caught_exception=ValueError())

def test_connection_timeouts_are_retried(self):
# If a connection times out, we get a Timout exception
# from requests. We should be retrying those.
handler = retryhandler.create_retry_handler(
self.retry_config, operation_name='OperationBar')
sleep_time = handler(response=None, attempts=1,
caught_exception=Timeout())
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

0 comments on commit 892be1f

Please sign in to comment.