Skip to content

Instantly share code, notes, and snippets.

@juanriaza
Created March 18, 2014 15:31
Show Gist options
  • Save juanriaza/9622417 to your computer and use it in GitHub Desktop.
Save juanriaza/9622417 to your computer and use it in GitHub Desktop.
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