Skip to content

Instantly share code, notes, and snippets.

@saghul
Created November 27, 2013 17:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save saghul/7679473 to your computer and use it in GitHub Desktop.
Save saghul/7679473 to your computer and use it in GitHub Desktop.
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