NameLost signal

Mikel Astiz mikel.astiz.oss at gmail.com
Thu Jan 24 23:45:45 PST 2013


Hi,

While debugging an issue with PulseAudio I came across an unexpected
D-Bus signal.

It seems that NameLost is also sent to the process voluntarily
releasing a service name. Is this expected?

To debug this easier I wrote the following script:

#!/usr/bin/python

import dbus
import dbus.mainloop.glib
import gobject

dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
bus = dbus.SessionBus()
service_name = "org.foo.bar.Test"

def signal_received(*args, **kargs):
    path = kargs["path"]
    name = kargs["name"]
    print("Signal %s received from %s" % (name, path))
    print("  %s" % str(args));

def start_test():
    print "Starting test sequence"
    bus.request_name(service_name)
    bus.release_name(service_name)
    print "Test sequence finished"

bus.add_signal_receiver(
    signal_received,
    dbus_interface=None,
    signal_name=None,
    path_keyword="path",
    member_keyword="name")

mainloop = gobject.MainLoop()
gobject.timeout_add(1000, start_test)
mainloop.run()

Tested with D-Bus 1.4.10, the resulting output is the following:

Signal NameAcquired received from /org/freedesktop/DBus
  (dbus.String(u':1.301'),)
Starting test sequence
Test sequence finished
Signal NameOwnerChanged received from /org/freedesktop/DBus
  (dbus.String(u'org.foo.bar.Test'), dbus.String(u''), dbus.String(u':1.301'))
Signal NameAcquired received from /org/freedesktop/DBus
  (dbus.String(u'org.foo.bar.Test'),)
Signal NameLost received from /org/freedesktop/DBus
  (dbus.String(u'org.foo.bar.Test'),)
Signal NameOwnerChanged received from /org/freedesktop/DBus
  (dbus.String(u'org.foo.bar.Test'), dbus.String(u':1.301'), dbus.String(u''))

Is believe this NameLost signal is undesirable. Am I missing something?

Cheers,
Mikel


More information about the dbus mailing list