Integrate tornado into other mainloop

200 views
Skip to first unread message

Tom

unread,
Mar 16, 2012, 2:10:33 AM3/16/12
to python-...@googlegroups.com
Hi,

i want to integrate the gmainloop (glib) into tornado.My webapp uses dbus calls to communicate with other processes and dbus doesn't like threads.
so i want to do one of the following things:
1) execute gmainloop.iterate() inside of the tornado mainloop and run
tornado.ioloop.IOLoop.instance().start() at the end
2) need an iterate() function from tornado which i can execute inside of the gmainloop. is something like this available?

TIA

Tom

Ben Darnell

unread,
Mar 16, 2012, 11:24:32 AM3/16/12
to python-...@googlegroups.com
I'd generally recommend giving each main loop its own thread (with
appropriately synchronized handoffs between them), as this is the only
way to ensure that each loop is available to respond to its own events
as soon as they arrive instead of waiting for a periodic callback from
the other. If that's not an option for gmainloop, the simplest thing
to do is to call gmainloop.iterate() in a Tornado PeriodicCallback.
Tornado doesn't currently have an equivalent iteration method,
although you might be able to construct one by doing something like

def iterate(io_loop):
io_loop.add_callback(io_loop.stop)
io_loop.start()

-Ben

Florian Ludwig

unread,
Mar 31, 2012, 12:58:18 PM3/31/12
to python-...@googlegroups.com
Hello Tom,

I am currently at the exact same task and would like to know which solution you did go with in the end. I hope you can share your experiences of integrating tornado and glib.

Thank you,
Florian
Reply all
Reply to author
Forward
0 new messages