Skip to content

Instantly share code, notes, and snippets.

@wolf0403
Last active December 10, 2015 01:58
Show Gist options
  • Save wolf0403/4363542 to your computer and use it in GitHub Desktop.
Save wolf0403/4363542 to your computer and use it in GitHub Desktop.
Tornado test script
#!/usr/bin/env python
import tornado.ioloop
import tornado.web
import tornado.process
import tornado.netutil
from tornado.httpserver import HTTPServer
import time
class MainHandler(tornado.web.RequestHandler):
def get(self, *args):
self.set_header ('Content-Type', 'text/plain')
#time.sleep (0.1)
self.write("tornado sleep (0.1)")
self.write (str (args))
application = tornado.web.Application([
(r"/(.*)", MainHandler),
], debug=False)
if __name__ == "__main__":
server = HTTPServer (application)
server.bind (9000)
server.start (2) # force two worker processes
tornado.ioloop.IOLoop.instance().start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment