Created
February 21, 2015 10:22
-
-
Save lmatt-bit/3b181fb879cd54792241 to your computer and use it in GitHub Desktop.
Tornado AsyncHttpClient simple example
This file contains hidden or 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 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