Skip to content
Myr

async: force prefetch=True on send

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

… otherwise we can run out of sockets before any of the responses are ever processed

authored by Chris Adams · committed by Chris Adams · parent 730c0e2 · Browse files · 1 file+5 added−8 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+5 added−8 removed

  • other:+5 added−8 removed

1 file+5 added−8 removed

modified:requests/async.py+5 added-8 removed
44 unmodified lines
4546 return wrapped474849def send(r, pool=None):50 """Sends the request object using the specified pool. If a pool isn't 49def send(r, pool=None, prefetch=False):50 """Sends the request object using the specified pool. If a pool isn't51 specified this method blocks. Pools are useful because you can specify size52 and can hence limit concurrency."""5354 if pool != None:55 return pool.spawn(r.send)55 return pool.spawn(r.send, prefetch=prefetch)5657 return gevent.spawn(r.send)57 return gevent.spawn(r.send, prefetch=prefetch)585960# Patched requests.api functions.61get = patched(api.get)
16 unmodified lines
7879 requests = list(requests)8081 pool = Pool(size) if size else None82 jobs = [send(r, pool) for r in requests]82 jobs = [send(r, pool, prefetch=prefetch) for r in requests]83 gevent.joinall(jobs)8485 if prefetch:86 [r.response.content for r in requests]8785 return [r.response for r in requests]