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.
This commit is contained in:
vitor-aignosi
2025-10-20 16:26:01 -03:00
parent f046d079b5
commit c2315a9455

View File

@@ -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)