spyoungtech / grequests

Requests + Gevent = <3
https://pypi.python.org/pypi/grequests
BSD 2-Clause "Simplified" License
4.46k stars 331 forks source link

Grequests timeout is not honored #32

Closed newmaniese closed 11 years ago

newmaniese commented 11 years ago

When making a request with Grequests, a timeout error is not raised. Here is a failing test:

def test_concurrency_with_timeout(self):
    n = 10
    reqs = []
    reqs.append(grequests.get(httpbin('delay/10'), timeout=1.5))
    resp = grequests.map(reqs)
    self.assertEqual([None], resp)
newmaniese commented 11 years ago

This actually appears to be a problem upstream. It is fixed, but a new release has not come out yet (New release has significant changes, tests pass in dev right now git://github.com/SiteSupport/gevent.git@bca8e7b):

https://bitbucket.org/denis/gevent/commits/65968cf1baa9/

This problem will also cause issues with the timeout in the standard requests library as well:

>>> import requests
>>> requests.get("http://httpbin.org/delay/6", timeout=1)
    Timeout: HTTPConnectionPool(host='httpbin.org', port=80): Request timed out. (timeout=1)
>>> from gevent import monkey as curious_george
>>> curious_george.patch_all(thread=False, select=False)
>>> requests.get("http://httpbin.org/delay/6", timeout=1)
    <Response [200]>
reclosedev commented 11 years ago

Not failing for me with gevent-1.0rc1.

newmaniese commented 11 years ago

On Gevent 1.0 (still in dev) this appears to be fixed

newmaniese commented 11 years ago

See also #1 which I have somehow missed