Tornado多进程启动的2种方法

单进程:

server = HTTPServer(app)
server.listen(8888)
IOLoop.instance().start()

多进程,方案1:

server = HTTPServer(app)
server.bind(8888)
server.start(0)  # Forks multiple sub-processes
IOLoop.instance().start()

多进程,方案2:

sockets = tornado.netutil.bind_sockets(8888)
tornado.process.fork_processes(0)
server = HTTPServer(app)
server.add_sockets(sockets)
IOLoop.instance().start()

 

Leave a Reply

Your email address will not be published. Required fields are marked *