Tornado: support for multiple applications on the same IOLoop

I am wondering if it is possible in Tornado to register multiple Application on the same IOLoop?

Sort of

application1 = web.Application([
    (r"/", MainPageHandler),
])
http_server = httpserver.HTTPServer(application1)
http_server.listen(8080)

application2 = web.Application([
    (r"/appli2", MainPageHandler2),
])
http_server2 = httpserver.HTTPServer(application2)
http_server2.listen(8080)

ioloop.IOLoop.instance().start()

I basically try to structure my webapp so that:

  • functional applications are divided
  • for each webapp several handlers are possible for the same purpose (for example, admin / monitoring / etc)
+5
source share
1 answer

The simple thing is if you had to bind your applications to different ports:

...
http_server = httpserver.HTTPServer(application1)
http_server.listen(8080)    # NOTE - port 8080

...
http_server2 = httpserver.HTTPServer(application2)
http_server2.listen(8081)   # NOTE - port 8081

ioloop.IOLoop.instance().start()

, Tornado . , URI , , URI, .

URI, , , ​​Nginx/Apache URI - , / .

+8

All Articles