Skip to content

Instantly share code, notes, and snippets.

@mudream4869
Created April 25, 2015 13:32
Show Gist options
  • Save mudream4869/36f7f3898e4daadaba30 to your computer and use it in GitHub Desktop.
Save mudream4869/36f7f3898e4daadaba30 to your computer and use it in GitHub Desktop.
coroutine test
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