Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tornado ioloop + threading

i have been working on tornado web framework from sometime, but still i didnt understood the ioloop functionality clearly, especially how to use it in multithreading. Is it possible to create separate instance of ioloop for multiple server ??

like image 523
Tejas Avatar asked Oct 19 '22 11:10

Tejas


1 Answers

The vast majority of Tornado apps should have only one IOLoop, running in 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 its own thread, but this is rarely useful, because the GIL ensures that only one thread is running at a time. If you do use multiple IOLoops you must be careful to ensure that the different threads only communicate with each other through thread-safe methods (i.e. IOLoop.add_callback).

like image 132
Ben Darnell Avatar answered Nov 04 '22 20:11

Ben Darnell