Skip to content

Instantly share code, notes, and snippets.

@bugaevc
Last active August 29, 2015 14:25
Show Gist options
  • Save bugaevc/1987a6557ff5f1427149 to your computer and use it in GitHub Desktop.
Save bugaevc/1987a6557ff5f1427149 to your computer and use it in GitHub Desktop.
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