Skip to content
Myr

Use socket.setdefaulttimeout(timeout) only if timeout argument doesn't exist (Python <2.6) - https://github.com/kennethreitz/requests/issues/112

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by JensDiemer · committed by JensDiemer · parent 49e5df1 · Browse files · 2 files+15 added−3 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+15 added−3 removed

  • other:+15 added−3 removed

2 files+15 added−3 removed

modified:requests/models.py+13 added-2 removed
36 unmodified lines
37 url=None, headers=dict(), files=None, method=None, data=dict(),38 params=dict(), auth=None, cookiejar=None, timeout=None, redirect=False,39 allow_redirects=False, proxies=None):4041 socket.setdefaulttimeout(timeout)41 #socket.setdefaulttimeout(timeout)42 self.timeout = timeout4344 #: Request URL.45 self.url = url46 #: Dictonary of HTTP Headers to attach to the :class:`Request <models.Request>`.
259 unmodified lines
306 if not self.sent or anyway:307308 try:309 opener = self._get_opener()310 try:311 resp = opener(req, timeout=self.timeout)312 except TypeError, err:313 # timeout argument is new since Python v2.6314 if not "timeout" in str(err):315 raise316 # set global socket timeout317 old_timeout = socket.getdefaulttimeout()318 socket.setdefaulttimeout(self.timeout)309 resp = opener(req)319 resp = opener(req)320 socket.setdefaulttimeout(old_timeout)321322 if self.cookiejar is not None:323 self.cookiejar.extract_cookies(resp, req)324
250 unmodified lines
modified:AUTHORS+2 added-1 removed
29 unmodified lines
30- 潘旭 (Xu Pan)31- Tamás Gulácsi32- Rubén Abad33- Peter Manser34- Jeremy Selie34- Jeremy Selie35- Jens Diemer