Skip to content

Commit

Permalink
Now, safe_mode will catch socket.timeout too.
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh Imhoff committed May 9, 2012
1 parent cff70e7 commit db43eb4
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions requests/safe_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
"""

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
Expand All @@ -27,7 +28,7 @@ def wrapped(method, url, **kwargs):
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
Expand Down

0 comments on commit db43eb4

Please sign in to comment.