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:
@@ -4,7 +4,7 @@
|
||||
"""D-Bus bus provider for revpi_middleware."""
|
||||
|
||||
from logging import getLogger
|
||||
from threading import Thread
|
||||
from threading import Thread, Event
|
||||
from typing import Union
|
||||
|
||||
import revpimodio2
|
||||
@@ -47,6 +47,7 @@ class BusProviderIos1(Thread):
|
||||
)
|
||||
|
||||
self.picontrol_device = picontrol_device
|
||||
self.published = Event()
|
||||
self.config_rsc = config_rsc
|
||||
|
||||
def run(self):
|
||||
@@ -90,6 +91,7 @@ class BusProviderIos1(Thread):
|
||||
InterfaceIoManager(self._lst_io_interfaces, self._modio),
|
||||
*lst_interfaces,
|
||||
)
|
||||
self.published.set()
|
||||
except Exception as e:
|
||||
log.error(f"can not publish dbus {REVPI_DBUS_NAME}: {e}")
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"""D-Bus bus provider for revpi_middleware."""
|
||||
|
||||
from logging import getLogger
|
||||
from threading import Thread
|
||||
from threading import Thread, Event
|
||||
from typing import Union
|
||||
|
||||
from gi.repository import GLib
|
||||
@@ -32,6 +32,7 @@ class BusProviderMiddleware1(Thread):
|
||||
self._loop = GLib.MainLoop()
|
||||
|
||||
self.picontrol_device = picontrol_device
|
||||
self.published = Event()
|
||||
self.config_rsc = config_rsc
|
||||
|
||||
def run(self):
|
||||
@@ -53,6 +54,7 @@ class BusProviderMiddleware1(Thread):
|
||||
REVPI_DBUS_NAME,
|
||||
*lst_interfaces,
|
||||
)
|
||||
self.published.set()
|
||||
except Exception as e:
|
||||
log.error(f"can not publish dbus {REVPI_DBUS_NAME}: {e}")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user