Skip to content
Myr

async module cleanups

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

authored by Kenneth Reitz · committed by Kenneth Reitz · parent 47b98bc · Browse files · 1 file+15 added−4 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+15 added−4 removed

  • other:+15 added−4 removed

1 file+15 added−4 removed

modified:requests/async.py+15 added-4 removed
21 unmodified lines
22from .hooks import dispatch_hook23from .packages.urllib3.poolmanager import PoolManager242526__all__ = (27 'map', 'get', 'head', 'post', 'put', 'patch', 'delete', 'request'28)29303132def _patched(f):27 """Patches a given api function to not send."""33 """Patches a given API function to not send."""3435 def wrapped(*args, **kwargs):36 return f(*args, _return_request=True, **kwargs)3738 return wrapped394041def _send(r, pools=None):36 """Dispatcher."""42 """Sends a given Request object."""4344 if pools:45 r._pools = pools46
6 unmodified lines
53 r.response = dispatch_hook('response', r.hooks, r.response)5455 return r.response565758# Patched requests.api functions.59get = _patched(api.get)60head = _patched(api.head)61post = _patched(api.post)
1 unmodified line
63patch = _patched(api.patch)64delete = _patched(api.delete)65request = _patched(api.request)6660from requests.sessions import session6768def map(requests, keep_alive=False):63 """Sends the requests... Asynchronously."""69 """Concurrently converts a list of Requests to Responses.7071 :param requests: a collection of Request objects.72 """7374 if keep_alive:75 pools = PoolManager(num_pools=len(requests), maxsize=1)76 else:77 pools = None
3 unmodified lines
8182 return [r.response for r in requests]83848586