Skip to content

Instantly share code, notes, and snippets.

@lmatt-bit
Created February 21, 2015 10:22
Show Gist options
  • Select an option

  • Save lmatt-bit/3b181fb879cd54792241 to your computer and use it in GitHub Desktop.

Select an option

Save lmatt-bit/3b181fb879cd54792241 to your computer and use it in GitHub Desktop.
Tornado AsyncHttpClient simple example
#from tornado.httpclient import HTTPClient
from tornado.httpclient import AsyncHTTPClient
import tornado.ioloop
#client = HTTPClient()
#res = client.fetch("http://www.baidu.com")
#print res.body
def handle_res(res):
if res.error:
print res.error
else:
print "success"
print res.body
aclient = AsyncHTTPClient()
aclient.fetch("http://www.baidu.com", handle_res)
print "async end"
tornado.ioloop.IOLoop.instance().start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment