Skip to content
Myr

#GH-241

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Juan Riaza · committed by Juan Riaza · parent 7ce305f · Browse files · 1 file+10 added−3 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+10 added−3 removed

  • other:+10 added−3 removed

1 file+10 added−3 removed

modified:requests/async.py+10 added-3 removed
10 unmodified lines
1112try:13 import gevent14 from gevent import monkey as curious_george15 from gevent.pool import Pool16except ImportError:17 raise RuntimeError('Gevent is required for requests.async.')1819# Monkey-patch.
41 unmodified lines
61delete = patched(api.delete)62request = patched(api.request)636464def map(requests, prefetch=True):65def map(requests, prefetch=True, size=None):66 """Concurrently converts a list of Requests to Responses.6768 :param requests: a collection of Request objects.69 :param prefetch: If False, the content will not be downloaded immediately.70 :param size: Specifies the number of requests to make at a time. If None, no throttling occurs.71 """7273 if size:74 pool = Pool(size)75 pool.map(send, requests)76 pool.join()77 else:71 jobs = [gevent.spawn(send, r) for r in requests]72 gevent.joinall(jobs)78 jobs = [gevent.spawn(send, r) for r in requests]79 gevent.joinall(jobs)8081 if prefetch:82 [r.response.content for r in requests]83
5 unmodified lines