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.
This commit is contained in:
2025-04-19 12:43:22 +02:00
parent 114cbd8099
commit 76b53423c1

View File

@@ -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):