-
Notifications
You must be signed in to change notification settings - Fork 330
Closed
Description
Currently, imap will not yield values returned by the exception handler and will not yield None values. However, responses from map will include values returned by the exception handler and will include None values.
Is there any reason why imap shouldn't be consistent with map in this way, at least for the exception handler?
Forgive me if I'm missing something, but I would have thought something like this would be appropriate.
for request in pool.imap_unordered(send, requests):
if request.response is not None:
yield request.response
elif exception_handler:
yield exception_handler(request, request.exception)
else: # probably leave this clause out
yield NoneIn other words, a and b should be the same in this example.
import grequests
req_list = [grequests.get('http://fakedomain')]
def ex_handler(req, ex):
return "foo"
a = grequests.map(req_list, exception_handler=ex_handler)
b = [item for item in grequests.imap(req_list, exception_handler=ex_handler)]But they are not
>>> a = grequests.map(req_list, exception_handler=ex_handler)
>>> b = [item for item in grequests.imap(req_list, exception_handler=ex_handler)]
>>> a
['foo']
>>> b
[]Metadata
Metadata
Assignees
Labels
No labels