Tornado ioloop + thread

I've been working on the tornado webmap since then, but I still haven't figured out the functionality of ioloop, especially how to use it in multi-threaded mode. Is it possible to create a separate ioloop instance for multiple servers?

+3


source to share


1 answer


The vast majority of Tornado applications should have only one IOLoop running on the main thread. You can run multiple HTTPServers (or other servers) on the same IOLoop.



It is possible to create multiple IOLoops and give each one their own thread, but this is rarely useful because the GIL ensures that only one thread is started at a time. If you are using multiple IOLoops, you have to be careful that different threads only communicate with each other using thread-safe methods (e.g. IOLoop.add_callback).

+3


source







All Articles