diff --git a/googleapiclient/http.py b/googleapiclient/http.py index f9d6a557e4c..5181badbeba 100644 --- a/googleapiclient/http.py +++ b/googleapiclient/http.py @@ -158,7 +158,7 @@ def _retry_request(http, num_retries, req_type, sleep, rand, uri, method, *args, except socket.error as socket_error: # errno's contents differ by platform, so we have to match by name. if socket.errno.errorcode.get(socket_error.errno) not in ( - 'WSAETIMEDOUT', 'ETIMEDOUT', ): + 'WSAETIMEDOUT', 'ETIMEDOUT', 'EPIPE', 'ECONNABORTED', ): raise exception = socket_error diff --git a/tests/test_http.py b/tests/test_http.py index b74e2cbf113..08450473a69 100644 --- a/tests/test_http.py +++ b/tests/test_http.py @@ -122,14 +122,19 @@ def request(self, *args, **kwargs): ex = TimeoutError() else: ex = socket.error() - # Initialize the timeout error code to the platform's error code. - try: - # For Windows: - ex.errno = socket.errno.WSAETIMEDOUT - except AttributeError: - # For Linux/Mac: - ex.errno = socket.errno.ETIMEDOUT - # Now raise the correct timeout error. + + if self.num_errors == 2: + #first try a broken pipe error (#218) + ex.errno = socket.errno.EPIPE + else: + # Initialize the timeout error code to the platform's error code. + try: + # For Windows: + ex.errno = socket.errno.WSAETIMEDOUT + except AttributeError: + # For Linux/Mac: + ex.errno = socket.errno.ETIMEDOUT + # Now raise the correct error. raise ex @@ -145,7 +150,7 @@ def request(self, *args, **kwargs): else: self.num_errors -= 1 ex = socket.error() - # Initialize the timeout error code to the platform's error code. + # set errno to a non-retriable value try: # For Windows: ex.errno = socket.errno.WSAECONNREFUSED