[python-dbus/PyQt] Message loops in separate threads
Simon McVittie
simon.mcvittie at collabora.co.uk
Mon Dec 17 01:53:53 PST 2007
On Sun, 16 Dec 2007 at 19:30:19 -0800, dwelch91 wrote:
> So, as a follow up to the PyQt/python-dbus issue connecting to both the
> session and system buses, should it be possible to place each messsge loop
> (Glib and PyQt) in a separate thread? Here's my naive attempt at this (that
> doesn't work). I guess I don't understand enough about the message loops to
> know whether this is completely misguided or not...
I believe that approach is misguided. Qt's QApplication wants to be run
in the main thread, while pygobject doesn't export enough C API for me
to run a main loop in a non-main thread (it always uses the default
GMainContext).
(Also, the semantics of DBusConnection are that if you ever make a blocking
method call on one thread, it takes a lock, and all API calls made by the
other thread on the same connection will block waiting for the lock until the
blocking method returns; this means you can't usefully make blocking calls on
the same connection from two threads.)
Simon
More information about the dbus
mailing list