From c2315a94553619a0860e7235b049e5994c4f29a5 Mon Sep 17 00:00:00 2001 From: vitor-aignosi Date: Mon, 20 Oct 2025 16:26:01 -0300 Subject: [PATCH] SIENTIAPDE-1312 Enhance OpcRepository client initialization and error handling - Updated the Client instantiation in OpcRepository to include a timeout and watchdog interval for improved connection management. - Added a disconnection call in the exception handling block to ensure proper resource cleanup during connection failures. --- laborious/utils/repository/opc_repository.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/laborious/utils/repository/opc_repository.py b/laborious/utils/repository/opc_repository.py index 619ff62..d53cf1b 100644 --- a/laborious/utils/repository/opc_repository.py +++ b/laborious/utils/repository/opc_repository.py @@ -130,7 +130,7 @@ class OpcRepository(BaseActivity): Exception: If the connection to the OPC server fails. """ - self.client = Client(self.url) # type: ignore[attr-defined] + self.client = Client(self.url, timeout=10, watchdog_intervall=3600000) # type: ignore[attr-defined] self.client.name = self.pod_id self.client.application_name = self.pod_id @@ -170,6 +170,8 @@ class OpcRepository(BaseActivity): await self.client.connect() return True, {} except Exception as e: + self.disconnect() + trace = traceback.format_exc() self.logger.custom_error(trace, self.metadata)