[dbus-python] signal filtering bug?

Wladimir van der Laan laanwj at gmail.com
Tue Dec 19 02:25:37 PST 2006


Hello,

It seems that conditional receive of signals does not work in
dbus-python (0, 51, 0) and  D-BUS Message Bus Daemon 0.60. As test
case I set up two simple programs, one is an service that sends a
signal every two seconds (send.py), and another program to receive
that signal (recv.py).

The signal has two arguments which are integers. As-is the programs do
what is expected, on each signal invocation both command_callback and
command147_callback get called.

Now the surprise: when I comment out section A, so to receive only
events with arg0=147, *nothing* is received at all. Even though all
the signals have arg0=147.

It seems that for some reason the event handler is not registered
properly. I cannot test this with a later version right now, but it
seems a serious problem.

# send.py
import gobject
import dbus
import dbus.service
import time

class TempObject(dbus.service.Object):
    def __init__(self, bus_name, object_path='/org/angeltech/Test'):
        dbus.service.Object.__init__(self, bus_name, object_path)

    @dbus.service.signal('org.angeltech.TestInterface')
    def command_signal(self, id, cmd):
        pass

def sendEvent(id, cmd):
    bus = dbus.SessionBus()

    bus_name = dbus.service.BusName('org.angeltech.TestService',bus=bus)
    object = TempObject(bus_name)
    while True:
        print "Sending signal"
        object.command_signal(id, cmd)
        time.sleep(2)

if __name__ == "__main__":
    sendEvent(147, 4)


# recv.py
import gobject
import dbus
import dbus.glib

def command_callback(id, cmd):
    print id,cmd

def command147_callback(id, cmd):
    print "Special: ",cmd


bus = dbus.SessionBus()

### section A: Works fine
bus.add_signal_receiver(command_callback,
    signal_name='command_signal',
    dbus_interface='org.angeltech.TestInterface'
)

### section B: Does not work
bus.add_signal_receiver(command147_callback,
    signal_name='command_signal',
    dbus_interface='org.angeltech.TestInterface',
    arg0=147
)

loop = gobject.MainLoop()
loop.run()


-- 
Wladimir
Ogre3D Team (http://www.ogre3d.org)


More information about the dbus mailing list