Skip to content

Commit

Permalink
Timeouts are normal errors now.
Browse files Browse the repository at this point in the history
--
BREAK ALL TEH TESTS!
  • Loading branch information
Kenneth Reitz committed Jun 22, 2011
1 parent 20aed54 commit 162b751
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
10 changes: 5 additions & 5 deletions requests/models.py
Expand Up @@ -296,15 +296,15 @@ def send(self, anyway=False):
if self.cookiejar is not None:
self.cookiejar.extract_cookies(resp, req)

except urllib2.HTTPError, why:
except (urllib2.HTTPError, urllib2.URLError), why:
if hasattr(why, 'reason'):
if isinstance(why.reason, socket.timeout):
why = Timeout(why)

self._build_response(why)
if not self.redirect:
self.response.error = why

# TODO: Support urllib connection refused errors

except urllib2.URLError, error:
raise Timeout if isinstance(error.reason, socket.timeout) else error
else:
self._build_response(resp)
self.response.ok = True
Expand Down
7 changes: 6 additions & 1 deletion test_requests.py
Expand Up @@ -246,8 +246,13 @@ def test_httpauth_recursion(self):


def test_settings(self):

def test():
r = requests.get(httpbin(''))
r.raise_for_status()

with requests.settings(timeout=0.0000001):
self.assertRaises(requests.Timeout, requests.get, httpbin(''))
self.assertRaises(requests.Timeout, test)

with requests.settings(timeout=100):
requests.get(httpbin(''))
Expand Down

0 comments on commit 162b751

Please sign in to comment.