System DBus does not recognize mainloop (Python)

Alexander betaev at gmail.com
Mon Mar 4 13:23:09 PST 2013


Hello,

I am trying to subscribe to events of UPower which runs on system DBus. I
use python-dbus and get the following:
    RuntimeError: To make asynchronous calls, receive signals or export
objects, D-Bus connections must be attached to a main loop by passing
mainloop=... to the constructor or calling dbus.set_default_main_loop(...)

Here is the code:
    def changed():
        print "changed"

    gtk.gdk.threads_init()
    dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)

    mainLoop = gobject.MainLoop()

    threading.Thread(target=mainLoop.run).start()
    dbus_system = dbus.SystemBus(mainloop=mainLoop)
    dbus_system.add_signal_receiver(changed, "Changed",
"org.freedesktop.UPower", "org.freedesktop.UPower",
"/org/freedesktop/UPower")

What am I doing wrong? I think I tried all ways to provide mainloop to
system bus object.


Thanks.

--
Best regards,
Alexander Betaev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/dbus/attachments/20130305/d161c227/attachment.html>


More information about the dbus mailing list