diff options
author | Siegfried-Angel Gevatter Pujals <siegfried@gevatter.com> | 2011-07-07 16:11:34 +0200 |
---|---|---|
committer | Siegfried-Angel Gevatter Pujals <siegfried@gevatter.com> | 2011-07-07 16:11:34 +0200 |
commit | 4ede295b5f8fdd043d9bc88de61237bfaa00ea79 (patch) | |
tree | d3234dbaacc68e93eaab16d7d969761dc9bfb4ee | |
parent | 75e35d5b55e4ff80b448c61f83c0df8a54730fe3 (diff) |
Python API: Fix reconnection so the method call triggering the
reconnection actually works when it is attempted again (LP: #736176).
-rw-r--r-- | NEWS | 2 | ||||
-rw-r--r-- | test/client-test.py | 5 | ||||
-rw-r--r-- | zeitgeist/client.py | 9 |
3 files changed, 7 insertions, 9 deletions
@@ -17,6 +17,8 @@ Python API: - Changed _DBusInterface to update introspected data after reconnections. - Added support for registering custom Event and Subject subclasses with ZeitgeistClient (LP: #799199). + - Fixed reconnection after a Zeitgeist restart so that the method call trig- + gering the reconnection also works -and not only later calls- (LP: #736176). - Added signal reconnection on engine restart for extensions (LP: #806967). - Added an "iteritems()" method to all enumerations (RelevantResultType, StorageState and ResultType). diff --git a/test/client-test.py b/test/client-test.py index bee16b74..325436d1 100644 --- a/test/client-test.py +++ b/test/client-test.py @@ -47,11 +47,6 @@ class DBusInterfaceReconnection(testutils.RemoteTestCase): self.spawn_daemon() # Can we still check for it? - try: - self.assertEquals(len(self.client._iface.GetEvents(ids)), 1) - except Exception: - print "\n==> The first method call after reconnecting failed!" - self.assertEquals(len(self.client._iface.GetEvents(ids)), 1) def testSignalReconnection(self): diff --git a/zeitgeist/client.py b/zeitgeist/client.py index b22c5887..44bf8101 100644 --- a/zeitgeist/client.py +++ b/zeitgeist/client.py @@ -72,7 +72,7 @@ class _DBusInterface(object): self.__iface = dbus.Interface(self.__proxy, self.__interface_name) self._load_introspection_data() - def _disconnection_safe(self, meth, *args, **kwargs): + def _disconnection_safe(self, method_name, *args, **kwargs): """ Executes the given method. If it fails because the D-Bus connection was lost, attempts to recover it and executes the method again. @@ -87,6 +87,7 @@ class _DBusInterface(object): self.reconnect() # We don't use the reconnecting_error_handler here since that'd # get us into an endless loop if Zeitgeist really isn't there. + meth = getattr(self.__iface, method_name) return meth(*args, **original_kwargs) else: if custom_error_handler is not None: @@ -101,9 +102,10 @@ class _DBusInterface(object): kwargs['error_handler'] = reconnecting_error_handler try: + meth = getattr(self.__iface, method_name) return meth(*args, **kwargs) except dbus.exceptions.DBusException, e: - reconnecting_error_handler(e) + return reconnecting_error_handler(e) def __getattr__(self, name): if name not in self.__methods and self.__methods is not None: @@ -113,8 +115,7 @@ class _DBusInterface(object): Method wrapping around a D-Bus call, which attempts to recover the connection to Zeitgeist if it got lost. """ - return self._disconnection_safe(getattr(self.__iface, name), - *args, **kwargs) + return self._disconnection_safe(name, *args, **kwargs) return _ProxyMethod def connect(self, signal, callback, **kwargs): |