Skip to content

Instantly share code, notes, and snippets.

@dhcmrlchtdj
Last active August 7, 2016 08:18
Show Gist options
  • Save dhcmrlchtdj/00a80d33bffbfbf230fe6836923f363b to your computer and use it in GitHub Desktop.
Save dhcmrlchtdj/00a80d33bffbfbf230fe6836923f363b to your computer and use it in GitHub Desktop.
tornado.httpclient.AsyncHTTPClient + asyncio
#!/usr/bin/env python3
from tornado.ioloop import IOLoop
from tornado.httpclient import AsyncHTTPClient
IOLoop.configure('tornado.platform.asyncio.AsyncIOLoop')
AsyncHTTPClient.configure('tornado.curl_httpclient.CurlAsyncHTTPClient')
async def example():
resp = await AsyncHTTPClient().fetch('https://google.com/')
print(resp.body)
IOLoop.instance().run_sync(example)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment