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&#39;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 = &#39;org.mozilla.thunderbird.DBus
&#39;<br>THUNDERBIRD_DBUS_PATH = &#39;/org/mozilla/thunderbird/DBus/NewMail&#39;<br><br>class ThunderBirdDBus(dbus.service.Object):<br>&nbsp;&nbsp;&nbsp; def __init__(self, bus_name):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dbus.service.Object.__init__(self, bus_name, THUNDERBIRD_DBUS_PATH)
<br><br>&nbsp;&nbsp;&nbsp; @dbus.service.signal(dbus_interface=THUNDERBIRD_DBUS_INTERFACE, signature=&#39;ss&#39;)<br>&nbsp;&nbsp;&nbsp; def NewMail(self, from_addr, subject):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 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(&quot;test&quot;, &quot;test&quot;)<br>