Thanks everyone for the help on this, but I'm not sure I follow what has been suggested. I have been playing around tonight with connecting the signals when I start the listener. For a simple test listener, I tried:<br>
<br>dbus_loop = DBusGMainLoop()<br>bus=dbus.SessionBus(mainloop=dbus_loop)<br>tbird_object = bus.get_object("org.mozilla.thunderbird.DBus" , '/org/mozilla/thunderbird/DBus')<br>interface = dbus.Interface
(tbird_object, "org.mozilla.thunderbird.DBus")<br>interface.connect_to_signal("NewMail", new_mail_callback)<br><br>But I get the error:<br><br>dbus.DBusException: org.freedesktop.DBus.Error.ServiceUnknown
: The name org.mozilla.thunderbird.DBus was not provided by any .service files<br><br>This problem is what led me down the path of connecting to the signals after registration.<br><br>The other problem was that it was starting those that were not yet started (for example, Rhythmbox would start if I tried to connect). I noticed the line "You shouldn't use proxy objects just to listen to signals, since they
might activate the relevant service when created, but if you already have a
proxy object in order to call methods, it's often convenient to use it to add
signal matches too." from the dbus-python tutorial, but it wasn't clear to me how to avoid this (by not using proxy objects).<br><br>Also, could you clarify what you mean by<br><br>" 2) request the current state that would be notified about by the signal"
<br><br>What kind of request is this? I'm hoping I can figure out how to implement what has been suggested, so it may not be a concern - I would just like to understand what you mean by this.<br><br>Thanks again,<br>Jim
<br><br><div><span class="gmail_quote">On 8/1/07, <b class="gmail_sendername">Havoc Pennington</b> <<a href="mailto:hp@redhat.com">hp@redhat.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Thiago Macieira wrote:<br>> Jim Kytola wrote:<br>>> For full disclosure, I have another script that listens for<br>>> NameOwnerChanged and when it finds the org.mozilla.thunderbird.DBus<br>>> change, connects a callback function to the NewMail signal - so by
<br>>> successful run, I mean the callback function gets fired. It's certainly<br>>> possible that my problem is on that side, but it does seem strange that<br>>> I'm seeing the NewMail signal before the GetNameOwner method call in
<br>>> the bad run.<br>><br>> This is your problem: you're waiting for the application to register.<br>><br>> Don't.<br>><br>> Connect the signal as soon as the listener starts. When the application
<br>> starts, register and emits the signal, your listener will have already<br>> set everything up. In fact, it won't even need to listen for the<br>> NameOwnerChanged signal.<br>><br><br>To add to this a bit, whenever you connect to a signal *after* the
<br>emitter exists you need to use this pattern:<br><br> 1) connect to signal<br> 2) request the current state that would be notified about by the signal<br><br>(in that order)<br><br>Any API with signals must have a way to do 2) or it's broken, because an
<br>app can't connect race-free.<br><br>But Thiago is certainly right that you need not wait for the bus name to<br>exist before you match for signals on it.<br><br>Havoc<br>_______________________________________________
<br>dbus mailing list<br><a href="mailto:dbus@lists.freedesktop.org">dbus@lists.freedesktop.org</a><br><a href="http://lists.freedesktop.org/mailman/listinfo/dbus">http://lists.freedesktop.org/mailman/listinfo/dbus</a><br>
</blockquote></div><br>