Skip to content

Instantly share code, notes, and snippets.

Created May 24, 2013 11:10
Show Gist options
  • Save anonymous/5642763 to your computer and use it in GitHub Desktop.
Save anonymous/5642763 to your computer and use it in GitHub Desktop.
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)
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