feat: Add published event to bus providers for thread synchronization

Introduced a threading `Event` named `published` in `bus_provider_ios1`
and `bus_provider_middleware1` modules to signal successful D-Bus
publishing.

Signed-off-by: Sven Sager <s.sager@kunbus.com>
This commit is contained in:
Sven Sager
2026-02-06 18:49:18 +01:00
parent 4ea8d6bc9a
commit 5dfd8b9f2f
2 changed files with 6 additions and 2 deletions

View File

@@ -4,7 +4,7 @@
"""D-Bus bus provider for revpi_middleware.""" """D-Bus bus provider for revpi_middleware."""
from logging import getLogger from logging import getLogger
from threading import Thread from threading import Thread, Event
from typing import Union from typing import Union
import revpimodio2 import revpimodio2
@@ -47,6 +47,7 @@ class BusProviderIos1(Thread):
) )
self.picontrol_device = picontrol_device self.picontrol_device = picontrol_device
self.published = Event()
self.config_rsc = config_rsc self.config_rsc = config_rsc
def run(self): def run(self):
@@ -90,6 +91,7 @@ class BusProviderIos1(Thread):
InterfaceIoManager(self._lst_io_interfaces, self._modio), InterfaceIoManager(self._lst_io_interfaces, self._modio),
*lst_interfaces, *lst_interfaces,
) )
self.published.set()
except Exception as e: except Exception as e:
log.error(f"can not publish dbus {REVPI_DBUS_NAME}: {e}") log.error(f"can not publish dbus {REVPI_DBUS_NAME}: {e}")

View File

@@ -4,7 +4,7 @@
"""D-Bus bus provider for revpi_middleware.""" """D-Bus bus provider for revpi_middleware."""
from logging import getLogger from logging import getLogger
from threading import Thread from threading import Thread, Event
from typing import Union from typing import Union
from gi.repository import GLib from gi.repository import GLib
@@ -32,6 +32,7 @@ class BusProviderMiddleware1(Thread):
self._loop = GLib.MainLoop() self._loop = GLib.MainLoop()
self.picontrol_device = picontrol_device self.picontrol_device = picontrol_device
self.published = Event()
self.config_rsc = config_rsc self.config_rsc = config_rsc
def run(self): def run(self):
@@ -53,6 +54,7 @@ class BusProviderMiddleware1(Thread):
REVPI_DBUS_NAME, REVPI_DBUS_NAME,
*lst_interfaces, *lst_interfaces,
) )
self.published.set()
except Exception as e: except Exception as e:
log.error(f"can not publish dbus {REVPI_DBUS_NAME}: {e}") log.error(f"can not publish dbus {REVPI_DBUS_NAME}: {e}")