Last active
August 29, 2015 14:25
-
-
Save bugaevc/1987a6557ff5f1427149 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
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