From: Leila Muhtasib Date: Fri, 13 Jul 2012 19:20:05 +0000 (-0400) Subject: Differentiate between two types of timeout errors from urllib3 X-Git-Tag: v0.13.4~12^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=318f2460eed225b7d369db3f07d4cc3445e70804;p=services%2Fpython-requests.git Differentiate between two types of timeout errors from urllib3 Bubble up error message from urllib3 to indicate to user whether error was a socket timeout vs a no connections available in connection pool error. Co-Authored By: Sarah Gonzalez --- diff --git a/requests/models.py b/requests/models.py index 8223f54..727654c 100644 --- a/requests/models.py +++ b/requests/models.py @@ -17,6 +17,7 @@ from .status_codes import codes from .auth import HTTPBasicAuth, HTTPProxyAuth from .cookies import cookiejar_from_dict, extract_cookies_to_jar, get_cookie_header from .packages.urllib3.exceptions import MaxRetryError, LocationParseError +from .packages.urllib3.exceptions import TimeoutError from .packages.urllib3.exceptions import SSLError as _SSLError from .packages.urllib3.exceptions import HTTPError as _HTTPError from .packages.urllib3 import connectionpool, poolmanager @@ -602,6 +603,8 @@ class Request(object): except (_SSLError, _HTTPError) as e: if isinstance(e, _SSLError): raise SSLError(e) + elif isinstance(e, TimeoutError): + raise Timeout(e) else: raise Timeout('Request timed out.')