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:
@@ -34,12 +34,19 @@ class BusProvider(Thread):
|
|||||||
def run(self):
|
def run(self):
|
||||||
log.debug("enter BusProvider.run")
|
log.debug("enter BusProvider.run")
|
||||||
|
|
||||||
self._bus.publish(
|
try:
|
||||||
REVPI_DBUS_NAME,
|
self._bus.publish(
|
||||||
InterfacePiControl(self.picontrol_device, self.config_rsc),
|
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")
|
log.debug("leave BusProvider.run")
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user