Created
March 18, 2014 15:31
-
-
Save juanriaza/9622417 to your computer and use it in GitHub Desktop.
This file contains 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 asyncio | |
import requests | |
@asyncio.coroutine | |
def main(): | |
loop = asyncio.get_event_loop() | |
future1 = loop.run_in_executor(None, requests.get, 'http://www.google.com') | |
future2 = loop.run_in_executor(None, requests.get, 'http://www.google.co.uk') | |
response1 = yield from future1 | |
response2 = yield from future2 | |
print(response1.text) | |
print(response2.text) | |
loop = asyncio.get_event_loop() | |
loop.run_until_complete(main()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment