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的调用不会互相阻塞