How to cope with restarted service?

Pavel Strashkin pavel.strashkin at
Thu Jan 27 12:43:37 PST 2011


To prevent from such situations you must call .get_object with
follow_name_owner_changes=True argument. In such case all calls will
be delivered to the bus using original service name (like a "service")
instead of unique (like a ":1.2") so everything will work even after
your service restart. One moment here. To use
"follow_name_owner_changes" you must setup main loop before or
get_object(...) will raise an exception.

bus = dbus.bus.BusConnection('...')
svc = bus.get_object('...', follow_name_owner_changes=True)

2011/1/27 W. Martin Borgert <debacle at>:
> Hi,
> I have a DBus service connected to the system bus written in C
> and a client written in Python.
> For some reasons the daemon behind the service needs to
> restarted sometimes. In consequence the client fails to connect
> the service again, because the unique name changed from e.g.
> ":1.122" to ":1.124".
> What is the best way to handle this? I tried reconnecting the
> Python client to DBus on the exception:
> DBusException: org.freedesktop.DBus.Error.ServiceUnknown:
> The name :1.122 was not provided by any .service files
> but to me this does not sound like a very elegant solution.
> Or is it possible that the service, which is unique in the
> system anyway, get's always the same address?
> Thanks in advance for any help!
> _______________________________________________
> dbus mailing list
> dbus at

More information about the dbus mailing list