Created
April 3, 2012 09:06
-
-
Save jholster/2290574 to your computer and use it in GitHub Desktop.
Tornado multiprocess example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tornado.web | |
import tornado.httpserver | |
import tornado.ioloop | |
class MainHandler(tornado.web.RequestHandler): | |
def get(self): | |
self.write("Greetings from the instance %s!" % tornado.process.task_id()) | |
app = tornado.web.Application([ | |
(r"/", MainHandler), | |
]) | |
if __name__ == "__main__": | |
server = tornado.httpserver.HTTPServer(app) | |
server.bind(8888) | |
server.start(0) # autodetect number of cores and fork a process for each | |
tornado.ioloop.IOLoop.instance().start() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@gwillem, http://www.tornadoweb.org/en/stable/guide/running.html#processes-and-ports