如何在龙卷风中在同一端口上的单独IOLoop上启动两个应用程序

时间:2019-02-13 06:01:49

标签: python tornado ioloop

import tornado
from tornado import httpserver
from tornado import web
from tornado.ioloop import IOLoop

class ServiceHandler1(tornado.web.RequestHandler):
    def initialize(self, *args, **kwargs):
        print "service1 handler"

class ServiceHandler2(tornado.web.RequestHandler):
    def initialize(self, *args, **kwargs):
        print "service2 handler"

def main():
    print "started main"
    application1 = web.Application([
        (r"/app1", ServiceHandler1),
        (r"/app2", ServiceHandler2),
    ])
    http_server = httpserver.HTTPServer(application1)
    http_server.listen(8080)

    print "start ioloop"
    tornado.ioloop.IOLoop.instance().start()

if __name__ == '__main__':
    main()
    print "started"

我想在一个ioloop中启动/ app1,在另一个ioloop中启动/ app2 这样对这些API的调用不会互相阻塞

0 个答案:

没有答案