Now, safe_mode will catch socket.timeout too.
authorJosh Imhoff <joshimhoff13@gmail.com>
Wed, 9 May 2012 19:13:12 +0000 (15:13 -0400)
committerJosh Imhoff <joshimhoff13@gmail.com>
Wed, 9 May 2012 19:13:12 +0000 (15:13 -0400)
requests/safe_mode.py

index 7a0f218be8c8a5964c78fa1c5b01e4ca1673ec44..619d368c7fa9ac79889b1e4a278f8c986f8c6a26 100644 (file)
@@ -12,8 +12,9 @@ This module contains a decorator that implements safe_mode.
 """
 
 from .models import Response
-from .exceptions import RequestException, ConnectionError, HTTPError
 from .packages.urllib3.response import HTTPResponse
+from .exceptions import RequestException, ConnectionError, HTTPError
+import socket
 
 def catch_exceptions_if_in_safe_mode(function):
     """New implementation of safe_mode. We catch all exceptions at the API level
@@ -27,7 +28,7 @@ def catch_exceptions_if_in_safe_mode(function):
                                             and kwargs.get('session').config.get('safe_mode')):
             try:
                 return function(method, url, **kwargs)
-            except (RequestException, ConnectionError, HTTPError) as e:
+            except (RequestException, ConnectionError, HTTPError, socket.timeout) as e:
                 r = Response()
                 r.error = e
                 r.raw = HTTPResponse() # otherwise, tests fail