spyoungtech / grequests

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

Differentiate HTTP errors like 404 from connection errors. #57

Closed natecode closed 8 years ago

natecode commented 10 years ago

With the previous code, a 404 or other HTTP error would result in:

Traceback (most recent call last): File "", line 1, in File "dload.py", line 16, in download_urls exception_handler=exception_handler): File "/app/lib/python2.7/site-packages/grequests.py", line 148, in imap exception_handler(request, request.exception) AttributeError: 'AsyncRequest' object has no attribute 'exception'

This is because gevent didn't store the exception in the request because an HTTP error does not cause an exception. We're in this case though because request.response evaluates to False if the Response was an HTTP error.

Also, can we get a release soon? Version 0.20 is kinda lacking without connection error handling. Thanks.

davilima6 commented 9 years ago

+1 for a release