Python Signal Emitter Race Condition Question

Simon McVittie simon.mcvittie at collabora.co.uk
Wed Aug 1 08:14:54 PDT 2007


On Wed, 01 Aug 2007 at 09:41:09 -0400, Jim Kytola wrote:
> 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?

What do you mean by "fully registered"?

Test case: if I remove the time.sleep() call from your code and run:

    dbus-launch sh -c 'dbus-monitor & sleep 1; python tbird.py; sleep 1'

I see events in this order:

signal NameOwnerChanged, name=:1.1, old="", new=:1.1 (tbird.py joins bus)
signal NameOwnerChanged, name=org.mozilla.thunderbird.DBus, old="", new=:1.1
    (tbird.py is given its desired bus name)
signal NewMail (tbird.py emits its signal)
signal NameOwnerChanged, name=org.mozilla.thunderbird.DBus, old=:1.1, new=""
    (tbird.py releases its bus name during shutdown)
signal NameOwnerChanged, name=:1.1, old=:1.1, new="" (tbird.py leaves bus)

This looks to me like the desired behaviour. What's the problem?

	Simon


More information about the dbus mailing list