python - using a signal not in introspection

Havoc Pennington hp at redhat.com
Wed Apr 25 16:58:58 PDT 2007


Hi,

John (J5) Palmieri wrote:
> I'm not sure I understand what the glib bindings do?  How do you use the
> name and not have a problem when it disconnects?  Are you saying we can
> use the bus name and not the unique name? 

Yes, if you don't care which owner of the bus name the signal is from 
(as you often don't) then you can just use the well-known name in the 
match rule and your rule will keep working as the owner changes.

I did just think of a race with the client-side tracking approach:

  AddMatch for first owner
  new owner takes over
  NameOwnerChanged emitted by bus
  new owner emits signal
  Signal dispatched by bus
  Receive NameOwnerChanged with new owner
  AddMatch for second owner

Note that a signal can be dispatched before the second AddMatch, so you 
would miss that signal.

To avoid this race while connecting to the unique name, generally you 
would need a GetCurrentState kind of method to get the state signaled by 
the signal; and you have to do:
  AddMatch
  GetCurrentState
(in that order)

I don't think you can do that automatically, the app would have to do it 
since it would have to know how to get the state.

> There was an issue at some
> point where we would not get signals if we used the bus name.  Perhaps
> that was a bug that was fixed?

I don't remember this, but it's possible I guess.

Havoc


More information about the dbus mailing list