-
-
Save saghul/7679473 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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