psf / requests

A simple, yet elegant, HTTP library.
https://requests.readthedocs.io/en/latest/
Apache License 2.0
52.17k stars 9.33k forks source link

Session timeout doesn't accept tuple? #2508

Closed ghost closed 9 years ago

ghost commented 9 years ago

Hi. Following the documentation, I've set a tuple with connect and read timeouts:

data = self.session.post('https://...', 
           data=params, 
           headers=headers, 
           timeout=(4.5, 10),
           verify=False).json()

But what I've got is this:

Timeout value connect was (4.5, 10), but it must be an int or float.

As stated in the developer API under request method, timeout should accept float or tuple, right? Thanks

kevinburke commented 9 years ago

Taking a look now

On Friday, March 20, 2015, Mateus Dalto Piveta notifications@github.com wrote:

Hi. Following the documentation http://docs.python-requests.org/en/latest/user/advanced/#timeouts, I've set a tuple with connect and read timeouts:

data = self.session.post('https://..., data=params, headers=headers, timeout=(4.5, 10), verify=False).json()

But what I've got is this:

Timeout value connect was (4.5, 10), but it must be an int or float.

As stated in the developer API http://docs.python-requests.org/en/latest/api/#request-sessions under request method, timeout should accept float or tuple, right? Thanks

— Reply to this email directly or view it on GitHub https://github.com/kennethreitz/requests/issues/2508.

Kevin Burke phone: 925.271.7005 | twentymilliseconds.com

Lukasa commented 9 years ago

What version of requests are you using?

Lukasa commented 9 years ago

The reason I ask is that with 2.6.0, I cannot reproduce this bug.

ghost commented 9 years ago

Requests 2.6.0 Python 3.4.0

Also, same error without using session

Lukasa commented 9 years ago

Once again, I do not reproduce this on requests 2.6.0 on Python 3.4.3 on OS X.

ghost commented 9 years ago

screen shot 2015-03-20 at 20 20 19

Ubuntu 14.04.2 =/

kevinburke commented 9 years ago

what is the urllib3 version? a single util.py file is fairly old..

Kevin Burke phone: 925.271.7005 | twentymilliseconds.com

On Fri, Mar 20, 2015 at 4:31 PM, Mateus Dalto Piveta < notifications@github.com> wrote:

[image: screen shot 2015-03-20 at 20 20 19] https://cloud.githubusercontent.com/assets/6289699/6762468/92405c54-cf3f-11e4-9ce9-66b619e9c49c.png

Ubuntu 14.04.2 =/

— Reply to this email directly or view it on GitHub https://github.com/kennethreitz/requests/issues/2508#issuecomment-84194385 .

kevinburke commented 9 years ago

sorry - what I am trying to suggest is that your requests version is 2.6.0, but the attached urllib3 version is part of your system packages and may be earlier, in a compatibility-breaking way.

Kevin Burke phone: 925.271.7005 | twentymilliseconds.com

On Fri, Mar 20, 2015 at 4:33 PM, Kevin Burke kev@inburke.com wrote:

what is the urllib3 version? a single util.py file is fairly old..

Kevin Burke phone: 925.271.7005 | twentymilliseconds.com

On Fri, Mar 20, 2015 at 4:31 PM, Mateus Dalto Piveta < notifications@github.com> wrote:

[image: screen shot 2015-03-20 at 20 20 19] https://cloud.githubusercontent.com/assets/6289699/6762468/92405c54-cf3f-11e4-9ce9-66b619e9c49c.png

Ubuntu 14.04.2 =/

— Reply to this email directly or view it on GitHub https://github.com/kennethreitz/requests/issues/2508#issuecomment-84194385 .

ghost commented 9 years ago

I've uninstalled the python3-urllib3 that comes with default installation (v1.7.1) and installed via pip v1.10.2, and now everything works :grin: Thank you guys