import time import tornado httpserver import tornado ioloop import tor

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import time
import tornado.httpserver
import tornado.ioloop
import tornado.web
class MainHandler(tornado.web.RequestHandler):
@tornado.web.asynchronous
def get(self):
tornado.ioloop.IOLoop.instance().add_callback(self._on_get)
def _on_get(self):
time.sleep(10)
self.write('Success')
self.finish()
application = tornado.web.Application([
(r"/", MainHandler),
])
if __name__ == "__main__":
http_server = tornado.httpserver.HTTPServer(application)
http_server.listen(8888)
print "listening on port " + str(8888)
tornado.ioloop.IOLoop.instance().start()