From 76b53423c11ea0c5c3c6ae10ea748e115701c1b2 Mon Sep 17 00:00:00 2001 From: Sven Sager Date: Sat, 19 Apr 2025 12:43:22 +0200 Subject: [PATCH] fix(dbus): Add error handling for DBus publishing and main loop Wrap DBus publishing and main loop execution in try-except blocks to capture and log failures. This ensures better visibility into errors and prevents silent failures during runtime. --- .../dbus_middleware1/bus_provider.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/revpi_middleware/dbus_middleware1/bus_provider.py b/src/revpi_middleware/dbus_middleware1/bus_provider.py index d3b6701..bc45d4a 100644 --- a/src/revpi_middleware/dbus_middleware1/bus_provider.py +++ b/src/revpi_middleware/dbus_middleware1/bus_provider.py @@ -34,12 +34,19 @@ class BusProvider(Thread): def run(self): log.debug("enter BusProvider.run") - self._bus.publish( - REVPI_DBUS_NAME, - InterfacePiControl(self.picontrol_device, self.config_rsc), - ) + try: + self._bus.publish( + REVPI_DBUS_NAME, + InterfacePiControl(self.picontrol_device, self.config_rsc), + ) + except Exception as e: + log.error(f"can not publish dbus {REVPI_DBUS_NAME}: {e}") + + try: + self._loop.run() + except Exception as e: + log.error(f"can not run dbus mainloop: {e}") - self._loop.run() log.debug("leave BusProvider.run") def stop(self):