-
-
Save mksh/5642769 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 zmq.eventloop import ioloop | |
ioloop.install() | |
from tornado.httpclient import AsyncHTTPClient | |
from tornado import gen | |
def handle_request(response): | |
if response.error: | |
print "Error:", response.error | |
else: | |
print response.code | |
#http_client = AsyncHTTPClient() | |
#http_client.fetch("http://www.google.com/", handle_request) | |
#http_client.fetch("http://ya.ru/", handle_request) | |
@gen.engine | |
def get(url1, url2): | |
print "get" | |
http_client = AsyncHTTPClient() | |
response1, response2 = yield [gen.Task(http_client.fetch, url1), gen.Task(http_client.fetch, url2)] | |
print response1 | |
print response2 | |
get("http://www.google.com/", "http://ya.ru/") | |
print "Async!" | |
ioloop.IOLoop.instance().start() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment