Python DBus Sending a Signal

Arigead captain.deadly at gmail.com
Mon Nov 30 04:33:37 PST 2009


Hello all,
    I was trying to send a signal from Python Dbus and tried to execute
the example given in the documentation at [1].  I can't seem to get this
code to run as it's giving me an error:

RuntimeError: To make asynchronous calls, receive signals or export
objects, D-Bus connections must be attached to a main loop by passing
mainloop=... to the constructor or calling dbus.set_default_main_loop(...)


I was on here recently to ask about remote DBus, and as I'm not trying
to do anything to complicated, and only want to receive one Signal I
decided that I'd do a simple socket message between machines and then
raise the DBus signal on the receiving side. My code [2]

That now seems impossible, if to send a DBus Signal I need to use the
deafult main loop. I was going to use a loop to receive from my socket.
Have the Python DBus innards changed since this example [1] was written?

Thanks for any advice

[1]
http://dbus.freedesktop.org/doc/dbus-python/doc/tutorial.html#emitting-signals-with-dbus-service-signal


[2]

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind((HOST, PORT))
s.listen(1)
conn, addr = s.accept()
print 'Connected by', addr
while 1:
    data = conn.recv(1024)
    if not data: break
    print 'Received Status %s' % data

    # SEND DBus SIGNAL Here
conn.close()


More information about the dbus mailing list