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:
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user