Hello,<br><br>I have been trying to implement a signal emitter in python (to be used in a Thunderbird extension), but have run into a bit of a race condition.<br><br>Using the below code (without the sleep call) I would almost always see the call to my emitter function before the object was fully registered on the dbus. If I add the sleep call, it works, however, the sleep (like I would expect) causes Thunderbird to hang for that time. Am I missing something here - does anyone have any suggestions for a better way to do what I'm trying to do?
<br><br>Thanks,<br>Jim<br><br>-----------------------------------<br><br>import dbus<br>import dbus.service<br>import time<br>from dbus.mainloop.glib import DBusGMainLoop<br><br>THUNDERBIRD_DBUS_INTERFACE = 'org.mozilla.thunderbird.DBus
'<br>THUNDERBIRD_DBUS_PATH = '/org/mozilla/thunderbird/DBus/NewMail'<br><br>class ThunderBirdDBus(dbus.service.Object):<br> def __init__(self, bus_name):<br> dbus.service.Object.__init__(self, bus_name, THUNDERBIRD_DBUS_PATH)
<br><br> @dbus.service.signal(dbus_interface=THUNDERBIRD_DBUS_INTERFACE, signature='ss')<br> def NewMail(self, from_addr, subject):<br> pass<br><br><br>dbus_loop = DBusGMainLoop()<br>name = dbus.service.BusName
(THUNDERBIRD_DBUS_INTERFACE, bus=dbus.SessionBus(mainloop=dbus_loop))<br><br>e = ThunderBirdDBus(name)<br>time.sleep(2)<br>e.NewMail("test", "test")<br>