diff libervia/web/server/server.py @ 1594:93abef9a3548

server: catch `DBusException` and retry to connect in this case.
author Goffi <goffi@goffi.org>
date Wed, 13 Dec 2023 22:03:49 +0100
parents 291a7026cb2b
children 86c7a3a625d5
line wrap: on
line diff
--- a/libervia/web/server/server.py	Mon Dec 11 00:43:06 2023 +0100
+++ b/libervia/web/server/server.py	Wed Dec 13 22:03:49 2023 +0100
@@ -27,6 +27,7 @@
 import urllib.parse
 import urllib.request
 
+from dbus.exceptions import DBusException
 from twisted.application import service
 from twisted.internet import defer, inotify, reactor
 from twisted.python import failure
@@ -648,7 +649,10 @@
         self.initialised.addCallback(lambda __: defer.ensureDeferred(self.backend_ready()))
 
     def _bridge_eb(self, failure_):
-        if isinstance(failure_, BridgeExceptionNoService):
+        if (
+                isinstance(failure_, BridgeExceptionNoService)
+                or isinstance(failure_, DBusException)
+        ):
             if self._bridge_retry:
                 if self._bridge_retry < 0:
                     print(_("Can't connect to bridge, will retry indefinitely. "
@@ -665,9 +669,9 @@
                 self.bridge.bridge_connect(callback=self._bridge_cb, errback=self._bridge_eb)
                 return
 
-            print("Can't connect to SàT backend, are you sure it's launched ?")
+            print("Can't connect to Libervia backend, are you sure it's launched?")
         else:
-            log.error("Can't connect to bridge: {}".format(failure))
+            log.exception("Can't connect to bridge")
         sys.exit(1)
 
     @property