Skip to content

Instantly share code, notes, and snippets.

@slingamn
Created July 12, 2012 21:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save slingamn/3100989 to your computer and use it in GitHub Desktop.
Save slingamn/3100989 to your computer and use it in GitHub Desktop.
# catch urllib3 exceptions and throw Requests exceptions
try:
# Send the request.
r = conn.urlopen(
method=self.method,
url=self.path_url,
body=body,
headers=self.headers,
redirect=False,
assert_same_host=False,
preload_content=False,
decode_content=False,
retries=self.config.get('max_retries', 0),
timeout=self.timeout,
)
self.sent = True
except MaxRetryError as e:
raise ConnectionError(e)
except (_SSLError, _HTTPError) as e:
if isinstance(e, _SSLError):
raise SSLError(e)
else:
raise Timeout('Request timed out.')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment