from time import time
import tornado.ioloop
import tornado.web
from threading import Timer
class MainHandler(tornado.web.RequestHandler):
@tornado.web.asynchronous
def get(self):
self.write("requested at " + str(time()))
Timer(10, self.on_response).start()
def on_response(self):
self.write("completed at " + str(time()))
self.finish()
class Application(tornado.web.Application):
def __init__(self):
handlers = [
(r"/", MainHandler),
]
tornado.web.Application.__init__(self, handlers)
if __name__ == "__main__":
app = Application()
app.listen(8888)
tornado.ioloop.IOLoop.instance().start()
Tornado 1.2.1 Python 2.7.1 ubuntu 11.04