fix: race-condition in PropertyObserver

When a proxy of a pydase client initialised with
block_until_connected=False is set as an attribute of a data service, a
race condition can happen: when the client connects while the
DataServiceObserver is being initialised, the property_deps_dict
attribute might not be set yet while the DataServiceObserver was already
added as an observer to the client proxy. The proxy will then emit a
notification, which in turn tries to get the dependent properties from
the property_deps_dict attribute, which has not been initialised yet.
The resulting exception will not tell the proxy that the client has
connected.
This commit is contained in:
Mose Müller
2025-07-08 15:28:22 +02:00
parent 265d9a7ef5
commit d55ba3a85f

View File

@@ -29,6 +29,7 @@ def get_property_dependencies(prop: property, prefix: str = "") -> list[str]:
class PropertyObserver(Observer):
def __init__(self, observable: Observable) -> None:
self.property_deps_dict: dict[str, list[str]] = {}
super().__init__(observable)
self._update_property_deps_dict()