Just use tornado.ioloop.IOLoop.instance()
. It choose best IOLoop for your platform.
if __name__ == "__main__":
application.listen(8888)
ioloop = tornado.ioloop.IOLoop.instance()
print ioloop # prints <tornado.platform.epoll.EPollIOLoop object at ..>
ioloop.start()
You should call self.finish()
if you use asynchronous
decorator:
If this decorator is given, the response is not finished when the method returns. It is up to the request handler to call self.finish() to finish the HTTP request. Without this decorator, the request is automatically finished when the get() or post() method returns.
class MainHandler(tornado.web.RequestHandler):
@web.asynchronous
@gen.engine
def get(self):
self.write("Hello, world")
self.finish()