Skip to content

Commit

Permalink
Catch ECONNRESET and other errors more reliably
Browse files Browse the repository at this point in the history
  • Loading branch information
dossett committed Dec 23, 2020
1 parent 70bc6c9 commit 9ea5e2d
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions googleapiclient/http.py
Expand Up @@ -28,17 +28,14 @@
from six import BytesIO, StringIO
from six.moves.urllib.parse import urlparse, urlunparse, quote, unquote

import base64
import copy
import gzip
import httplib2
import json
import logging
import mimetypes
import os
import random
import socket
import sys
import time
import uuid

Expand Down Expand Up @@ -190,11 +187,16 @@ def _retry_request(
exception = connection_error
except socket.error as socket_error:
# errno's contents differ by platform, so we have to match by name.
# Some of these same errors may have been caught above, e.g. ECONNRESET *should* be
# raised as a ConnectionError, but some libraries will raise it as a socket.error
# with an errno corresponding to ECONNRESET
if socket.errno.errorcode.get(socket_error.errno) not in {
"WSAETIMEDOUT",
"ETIMEDOUT",
"EPIPE",
"ECONNABORTED",
"ECONNREFUSED",
"ECONNRESET",
}:
raise
exception = socket_error
Expand Down

0 comments on commit 9ea5e2d

Please sign in to comment.