prefetch=False for async.map
authorKenneth Reitz <me@kennethreitz.com>
Fri, 14 Oct 2011 01:10:34 +0000 (21:10 -0400)
committerKenneth Reitz <me@kennethreitz.com>
Fri, 14 Oct 2011 01:10:34 +0000 (21:10 -0400)
requests/async.py

index c3801b3817ba96e4707ad4f68ed434f256908f3f..db25f6a597916a0fbf156d43eb0222f0b627321b 100644 (file)
@@ -64,16 +64,19 @@ delete = _patched(api.delete)
 request = _patched(api.request)
 
 
-def map(requests):
+def map(requests, prefetch=True):
     """Concurrently converts a list of Requests to Responses.
 
     :param requests: a collection of Request objects.
-    :param keep_alive: If True, HTTP Keep-Alive will be used.
+    :param prefetch: If False, the content will not be downloaded immediately.
     """
 
     jobs = [gevent.spawn(_send, r) for r in requests]
     gevent.joinall(jobs)
 
+    if prefetch:
+        [r.response.content for r in requests]
+
     return [r.response for r in requests]