def fetch_multiple_urls_async(req_data):
start_time = time_ms()
# start the threads (greenlets)
threads_ = []
for u in req_data:
new_thread = gevent.spawn(fetch_url_async, u)
threads_.append(new_thread)
# wait for threads to finish
gevent.joinall(threads_)
# retrieve threads return values
results = []
for t in threads_:
rresult = t.get(block=True, timeout=6.0)
rresult['start_time'] = start_time
results.append(rresult)
return results
# process a batch of responses
评论列表
文章目录