From 0d5cef1537a94445a9cc6bc726004dd95a2874e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mose=20M=C3=BCller?= Date: Tue, 1 Oct 2024 10:54:27 +0200 Subject: [PATCH] updates how Client handles (re-)connection with the server The client will update the proxy class serialization directly on the ProxyClass instance. this is the only time this get "updated". Now, the client also notifies the observers directly with the proxy object as this the serialization of the proxy class is now done through its `serialize` method (which we have overwritten in a previous commit). --- src/pydase/client/client.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/pydase/client/client.py b/src/pydase/client/client.py index 079aca6..6827edc 100644 --- a/src/pydase/client/client.py +++ b/src/pydase/client/client.py @@ -2,7 +2,7 @@ import asyncio import logging import sys import threading -from typing import TypedDict, cast +from typing import TYPE_CHECKING, TypedDict, cast import socketio # type: ignore @@ -121,7 +121,13 @@ class Client: self.proxy, serialized_object=serialized_object ) serialized_object["type"] = "DeviceConnection" - self.proxy._notify_changed("", loads(serialized_object)) + if self.proxy._service_representation is not None: + # need to use object.__setattr__ to not trigger an observer notification + object.__setattr__(self.proxy, "_service_representation", serialized_object) + + if TYPE_CHECKING: + self.proxy._service_representation = serialized_object # type: ignore + self.proxy._notify_changed("", self.proxy) self.proxy._connected = True async def _handle_disconnect(self) -> None: