From b80ffac53291a45d5239e7476580d0eeac0af738 Mon Sep 17 00:00:00 2001 From: "Hailu, Mikael" Date: Thu, 23 Nov 2023 14:58:02 +0100 Subject: [PATCH] Refactor sync.client.conncect & sync.server.start Reopen ThreadLoop if stopped previously analogous to init Fixes #1364 --- asyncua/sync.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/asyncua/sync.py b/asyncua/sync.py index 63993f594..9f334839c 100644 --- a/asyncua/sync.py +++ b/asyncua/sync.py @@ -249,9 +249,12 @@ def application_uri(self): def application_uri(self, value): self.aio_obj.application_uri = value - @syncmethod def connect(self) -> None: - pass + if not self.tloop.is_alive(): + self.tloop = ThreadLoop() + self.tloop.start() + self.close_tloop = True + self.tloop.post(self.aio_obj.connect()) def disconnect(self) -> None: try: @@ -592,9 +595,12 @@ def register_namespace(self, url): def get_namespace_array(self): pass - @syncmethod def start(self): - pass + if not self.tloop.is_alive(): + self.tloop = ThreadLoop() + self.tloop.start() + self.close_tloop = True + self.tloop.post(self.aio_obj.start()) def stop(self): self.tloop.post(self.aio_obj.stop())