Advertisement
Azelphur

Untitled

Jun 1st, 2011
460
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.49 KB | None | 0 0
  1. #import tornado.ioloop
  2. import tornado.web
  3. import time
  4. from threading import Timer
  5.  
  6. class MainHandler(tornado.web.RequestHandler):
  7.     @tornado.web.asynchronous
  8.     def get(self):
  9.         t = Timer(5.0, self.on_response)
  10.         t.start()
  11.         print 'thread started'
  12.  
  13.     def on_response(self):
  14.         self.write(str(time.time()))
  15.         self.finish()
  16.  
  17. application = tornado.web.Application([
  18.     (r"/", MainHandler),
  19. ])
  20.  
  21. if __name__ == "__main__":
  22.     application.listen(8888)
  23.     tornado.ioloop.IOLoop.instance().start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement