Skip to content

Commit

Permalink
Merge pull request #220 from rctay/rc/191-ssl-gae
Browse files Browse the repository at this point in the history
googleapiclient.http: guard when importing ssl.
  • Loading branch information
nathanielmanistaatgoogle committed Apr 28, 2016
2 parents 133b9ff + 3146c92 commit 6d9ba51
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions googleapiclient/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,18 @@
import os
import random
import socket
import ssl
import sys
import time
import uuid

# TODO(issue 221): Remove this conditional import jibbajabba.
try:
import ssl
except ImportError:
_ssl_SSLError = object()
else:
_ssl_SSLError = ssl.SSLError

from email.generator import Generator
from email.mime.multipart import MIMEMultipart
from email.mime.nonmultipart import MIMENonMultipart
Expand Down Expand Up @@ -146,7 +153,7 @@ def _retry_request(http, num_retries, req_type, sleep, rand, uri, method, *args,
exception = None
resp, content = http.request(uri, method, *args, **kwargs)
# Retry on SSL errors and socket timeout errors.
except ssl.SSLError as ssl_error:
except _ssl_SSLError as ssl_error:
exception = ssl_error
except socket.error as socket_error:
# errno's contents differ by platform, so we have to match by name.
Expand Down

0 comments on commit 6d9ba51

Please sign in to comment.