spyoungtech / grequests

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

Created empty response when request throws Exception #113

Closed jtemporal closed 5 years ago

jtemporal commented 7 years ago

Whenever an Exception is thrown by setting the self.response variable to an empty Response object allows anyone to easily mock the response information.

Where is this PR coming from:

I wanted to create an exception_handler that returns an response object with status_code set to 404 without having to import requests along side grequests.

Oxicode commented 5 years ago

+1

spyoungtech commented 5 years ago

As described in #126 you can actually use the exception handler to return whatever you'd like in the case of an exception. This is a pretty flexible option which one can use to achieve this effect; the power is in your hands.

Notably, prior to #126 being merged, this was not the case for grequests.imap where the exception handlers return value would be disregarded.

As such, will be closing this one for now, feel free to reopen for discussion.