I realize there have been many posts on grequests such as Asynchronous Requests with Python requests
which describes the basic usage of grequests and how to send hooks via grequests.get()
I pulled this bit of code right from that link.
import grequests
urls = [
'http://python-requests.org',
'http://httpbin.org',
'http://python-guide.org',
'http://kennethreitz.com'
]
# A simple task to do to each response object
def do_something(response):
print ('print_test')
# A list to hold our things to do via async
async_list = []
for u in urls:
action_item = grequests.get(u, hooks = {'response' : do_something})
async_list.append(action_item)
# Do our list of things to do via async
grequests.map(async_list)
When i run this however i get no output
/$ python test.py
/$
since there are 4 links I would expect the output to be
print_test
print_test
print_test
print_test
I have been searching around and haven't been able to find a reason for the lack of output I am amusing that there is a bit of key information that I am missing.