Created
April 25, 2015 13:32
-
-
Save mudream4869/36f7f3898e4daadaba30 to your computer and use it in GitHub Desktop.
coroutine test
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 | |
@tornado.gen.coroutine | |
def getstr(): | |
raise tornado.gen.Return("Hello coroutine") | |
class MainHandler(tornado.web.RequestHandler): | |
@tornado.gen.coroutine | |
def get(self): | |
gs = yield getstr() | |
self.write(gs) | |
application = tornado.web.Application([ | |
(r"/", MainHandler), | |
]) | |
if __name__ == "__main__": | |
application.listen(8888) | |
tornado.ioloop.IOLoop.current().start() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment