Hello,<br><br>I am trying to subscribe to events of UPower which runs on system DBus. I use python-dbus and get the following:<br> 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(...)<br><div id=":1h8">
<br>Here is the code:<br> def changed():<br> print "changed"
<br><br> gtk.gdk.threads_init()<br> dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)<br> <br> mainLoop = gobject.MainLoop()<br> <br> threading.Thread(target=mainLoop.run).start()<br> dbus_system = dbus.SystemBus(mainloop=mainLoop)<br>
dbus_system.add_signal_receiver(changed, "Changed", "org.freedesktop.UPower", "org.freedesktop.UPower", "/org/freedesktop/UPower")<br><br>What am I doing wrong? I think I tried all ways to provide mainloop to system bus object.<br>
<br><br>Thanks.<br>
<br><div><div>--<br>Best regards,<br>Alexander Betaev</div></div></div>