From 318f2460eed225b7d369db3f07d4cc3445e70804 Mon Sep 17 00:00:00 2001 From: Leila Muhtasib Date: Fri, 13 Jul 2012 15:20:05 -0400 Subject: [PATCH] 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 --- requests/models.py | 3 +++ 1 file changed, 3 insertions(+) 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.') -- 2.7.4