-
-
Save codeboy/b5b2cdfb0f03dfa328b5 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
import tornado.ioloop | |
import tornado.web | |
import tornado.gen | |
import tornado.httpclient | |
class GenAsyncHandler(tornado.web.RequestHandler): | |
@tornado.web.asynchronous | |
@tornado.gen.engine | |
def get(self): | |
http_client = tornado.httpclient.AsyncHTTPClient() | |
response = yield tornado.gen.Task(http_client.fetch, "http://example.com") | |
print response, dir(response) | |
print response.error | |
self.finish('Fin.') | |
application = tornado.web.Application([ | |
(r"/", GenAsyncHandler), | |
]) | |
if __name__ == "__main__": | |
application.listen(8889) | |
tornado.ioloop.IOLoop.instance().start() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment