Skip to content

Instantly share code, notes, and snippets.

@bugaevc bugaevc/tornado_google.py
Last active Aug 29, 2015

Embed
What would you like to do?
from tornado.httpclient import AsyncHTTPClient
import tornado.gen
import tornado.ioloop
import timeit
@tornado.gen.coroutine
def make_request(index):
client = AsyncHTTPClient()
print(index, 'started')
response = yield client.fetch('http://google.com', raise_error=False)
print(index, response.code)
@tornado.gen.coroutine
def main():
yield [make_request(i) for i in range(5)]
print(timeit.timeit(lambda: tornado.ioloop.IOLoop.current().run_sync(main), number=1))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.