From b4f88480db99d7b5f8266c16d07f8e7cd0c18c55 Mon Sep 17 00:00:00 2001 From: Goffi Date: Thu, 8 Oct 2026 16:25:07 +0200 Subject: [PATCH] bridge (dbus): export the D-Bus name only once the plugins are loaded: client connecting too early were seeing an incomplete plugin interface. --- .../constructors/dbus/dbus_core_template.py | 7 ++++--- libervia/backend/bridge/dbus_bridge.py | 7 ++++--- libervia/backend/core/main.py | 5 +++++ 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/libervia/backend/bridge/bridge_constructor/constructors/dbus/dbus_core_template.py b/libervia/backend/bridge/bridge_constructor/constructors/dbus/dbus_core_template.py index 139bee64..4496cfe5 100644 --- a/libervia/backend/bridge/bridge_constructor/constructors/dbus/dbus_core_template.py +++ b/libervia/backend/bridge/bridge_constructor/constructors/dbus/dbus_core_template.py @@ -123,7 +123,7 @@ class bridge: async def post_init(self): try: - conn = await client.connect(reactor) + self.conn = await client.connect(reactor) except error.DBusException as e: if e.errName == "org.freedesktop.DBus.Error.NotSupported": log.error( @@ -134,8 +134,9 @@ class bridge: ) raise BridgeInitError(str(e)) - conn.exportObject(self._obj) - await conn.requestBusName(const_INT_PREFIX) + async def export(self): + self.conn.exportObject(self._obj) + await self.conn.requestBusName(const_INT_PREFIX) ##SIGNALS_PART## def register_method(self, name, callback): diff --git a/libervia/backend/bridge/dbus_bridge.py b/libervia/backend/bridge/dbus_bridge.py index 514f13ff..09ed5a0a 100644 --- a/libervia/backend/bridge/dbus_bridge.py +++ b/libervia/backend/bridge/dbus_bridge.py @@ -571,7 +571,7 @@ class bridge: async def post_init(self): try: - conn = await client.connect(reactor) + self.conn = await client.connect(reactor) except error.DBusException as e: if e.errName == "org.freedesktop.DBus.Error.NotSupported": log.error( @@ -582,8 +582,9 @@ class bridge: ) raise BridgeInitError(str(e)) - conn.exportObject(self._obj) - await conn.requestBusName(const_INT_PREFIX) + async def export(self): + self.conn.exportObject(self._obj) + await self.conn.requestBusName(const_INT_PREFIX) def _debug(self, action, params, profile): self._obj.emitSignal("_debug", action, params, profile) diff --git a/libervia/backend/core/main.py b/libervia/backend/core/main.py index b5ffedc5..b7dd09f0 100644 --- a/libervia/backend/core/main.py +++ b/libervia/backend/core/main.py @@ -305,6 +305,11 @@ class LiberviaBackend(service.Service): log.exception(f"Could not initialize backend") self.stop(exit_code=C.EXIT_ERROR) return + # the bridge must be exported only once the plugins have been imported, so + # that clients can introspect the whole plugin interface + if hasattr(self.bridge, "export"): + await self.bridge.export() + self._add_base_menus() self.init_pre_script.callback(None)