problem when closing Dbus
simon.mcvittie at collabora.co.uk
Mon Jun 25 05:16:51 PDT 2007
-----BEGIN PGP SIGNED MESSAGE-----
Please use dbus at lists.freedesktop.org (cc'd) for dbus-python support questions,
rather than emailing me personally, so the answers can benefit others.
On Mon, 25 Jun 2007 at 13:19:33 +0200, yann wrote:
> yann a écrit :
> >We've got a little problem with dbus in Gajim. When we close it
> >(/etc/init.d/messagebus stop) That silently closes Gajim.
> I investigated a bit more, and found that it's only when I access the
> system bus. More precisely, if I comment the line
> bus = system_bus.SystemBus()
> and follwings in
> I don't have the problem anymore.
By default, libdbus calls _exit() when it becomes disconnected from the
bus daemon - this is because it's impossible to make guarantees about
how many messages you'll lose before you're able to reconnect.
(As you've discovered, if you don't connect to the system bus, you're not
affected by the system bus stopping.)
You can disable this "feature" by calling
set_exit_on_disconnect(False) on your Bus instance.
When you get disconnected, you will receive a D-Bus signal Disconnected
on the special reserved interface org.freedesktop.DBus.Local, from the
special reserved object-path /org/freedesktop/DBus/Local. You can catch
this signal and do something useful (e.g. perhaps scheduling a reconnect
attempt in a few seconds' time).
When you've reconnected (which you must do by creating a new instance of
Bus - using private connections with SystemBus(private=True) will make
this less confusing) you will have a different unique-name and you'll
have lost all the connection state (signal handlers, etc.) so must reconnect
any signal handlers you want. You will also have missed an arbitrary number
of messages, so must start again by e.g. re-querying Network Manager for
its current state - in general, you'll need to behave as though you'd
just started up.
Exiting or restarting the system bus is considered to be an unsupported action
by the D-Bus core developers, who appear to believe that restarting
the system bus is equivalent to replacing the kernel, and requires a
reboot, while restarting the session bus requires a session restart (i.e. log
out and back in). I must admit I'm not really happy about this,
particularly for programs where D-Bus interaction is a minor part of the
overall functionality (e.g. things that just want to watch NetworkManager
so they can tell whether you're online), but there's no other simple
solution (you either have to abort, or cope with the disconnection in a
fairly extensive way).
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: OpenPGP key: http://www.pseudorandom.co.uk/2003/contact/ or pgp.net
-----END PGP SIGNATURE-----
More information about the dbus