Skip to content
Myr

The async.send method wasn't really doing anything useful. It was just calling the r.send() method of the Request object 'r'. It took an optional kwarg pools, and assigned it to r._pools which isn't used by anything. This situation was eaither broken or not fully implemented yet. I modified async.map to call r.send rather than send(r) and then modified async.send to actually make use of the pool that it is passed.

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

authored by Ben · committed by Ben · parent df0dc2b · Browse files · 1 file+13 added−16 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+13 added−16 removed

  • other:+13 added−16 removed

1 file+13 added−16 removed

modified:requests/async.py+13 added-16 removed
44 unmodified lines
4546 return wrapped474849def send(r, pools=None):50 """Sends a given Request object."""49def send(r, pool=None):50 """Sends the request object using the specified pool. If a pool isn't 51 specified this method blocks. Pools are useful because you can specify size52 and can hence limit concurrency."""5352 if pools:53 r._pools = pools54 if pool != None:55 print pool.full()56 return pool.spawn(r.send)5755 r.send()58 return gevent.spawn(r.send)5957 return r.response605961# Patched requests.api functions.62get = patched(api.get)63options = patched(api.options)64head = patched(api.head)
15 unmodified lines
80 requests = list(requests)8182 if size:83 pool = Pool(size)83 pool.map(send, requests)84 pool.join()84 jobs = [pool.spawn(r.send) for r in requests]85 else:86 jobs = [gevent.spawn(send, r) for r in requests]87 gevent.joinall(jobs)86 jobs = [gevent.spawn(r.send) for r in requests]87 88 gevent.joinall(jobs)8990 if prefetch:91 [r.response.content for r in requests]9292 return [r.response for r in requests]9394959693 return [r.response for r in requests]