Bug#934743: python-networkmanager: org.freedesktop.DBus.Error.ServiceUnknown if NetworkManager service restarts

2019-08-14 Thread Simon McVittie
On Wed, 14 Aug 2019 at 11:19:31 +0200, Ana Rodriguez Lopez wrote:
> If NetworkManager service restarts, it gets a new dbus unix process id.

The term you're looking for here is "D-Bus unique name".

> The parameter follow_name_owner_changes can be used in get_object()
> calls to prevent this.

FYI this is only valid if the proxy either doesn't remember the state
of the remote object, or forgets that state when the name owner's unique
name changes, which is why it isn't the default. (I don't know whether
NM's D-Bus API is stateful or stateless, so I can't say whether this
patch is correct or not.)

smcv



Bug#934743: python-networkmanager: org.freedesktop.DBus.Error.ServiceUnknown if NetworkManager service restarts

2019-08-14 Thread Ana Rodriguez Lopez
Package: python3-networkmanager
Version: 2.1-2
Tags: patch
Forwarded: https://github.com/seveas/python-networkmanager/issues/66

If NetworkManager service restarts, it gets a new dbus unix process id.
The python-networkmanager remains with the old id. since this process
doesn't exist any more, a org.freedesktop.DBus.Error.ServiceUnknown
exception is thrown.

The parameter follow_name_owner_changes can be used in get_object()
calls to prevent this.

diff --git a/NetworkManager.py b/NetworkManager.py
index 3d137fe..00f0729 100644
--- a/NetworkManager.py
+++ b/NetworkManager.py
@@ -258,7 +258,7 @@ def __eq__(self, other):
 @property
 def proxy(self):
 if not self._proxy:
-self._proxy =
dbus.SystemBus().get_object(self.dbus_service, self.object_path)
+self._proxy =
dbus.SystemBus().get_object(self.dbus_service, self.object_path,
follow_name_owner_changes=True)
 self._proxy.created = time.time()
 elif self._proxy.created < self.last_disconnect:
 if self.is_transient:


https://github.com/anrodlo/python-networkmanager/commit/88f1b0e4531f80e17af3ffe00b5816800ebb4c1a.diff