Skip to content

Instantly share code, notes, and snippets.

@saghul

saghul/t.py

Created Nov 27, 2013
Embed
What would you like to do?
import erequests
urls = [
'http://www.heroku.com',
'http://tablib.org',
'http://httpbin.org',
'http://python-requests.org',
'http://kennethreitz.com'
]
# sync API (spawns a new green thread and waits for it)
for url in urls:
print erequests.get(url)
# async API (prepares the requests, they are sent with map/imap)
reqs = [erequests.async.get(url) for url in urls]
print list(erequests.imap(reqs))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment