Skip to content

Commit

Permalink
1.Remove invalid context management
Browse files Browse the repository at this point in the history
2.Improve the example and actively release the connection
  • Loading branch information
Tracersboy committed Dec 11, 2024
1 parent 3539363 commit 09dc841
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 2 additions & 0 deletions examples/connect_discover_read_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ def main():
start = time.time()
properties = opc_client.properties(tags)
print(f'{n} {time.time()-start:.3f}s {properties}')
opc_client.close() # Remote call OpcDaClient. close()
opc_client._pyroRelease() # release the pyro connection


if __name__ == '__main__':
Expand Down
8 changes: 4 additions & 4 deletions openopc2/gateway_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ def __init__(self, host: str = 'localhost', port: int = 7766):
register_dict_to_class("exceptions.OPCError", OPCError.dict_to_class)

def get_server_proxy(self):
with Pyro5.client.Proxy(f"PYRO:OpenOpcGatewayServer@{self.host}:{self.port}") as open_opc_gateway_server:
return open_opc_gateway_server
open_opc_gateway_server = Pyro5.client.Proxy(f"PYRO:OpenOpcGatewayServer@{self.host}:{self.port}")
return open_opc_gateway_server

def get_opc_da_client_proxy(self):
with Pyro5.client.Proxy(f"PYRO:OpcDaClient@{self.host}:{self.port}") as opc_da_client_proxy:
return opc_da_client_proxy
opc_da_client_proxy = Pyro5.client.Proxy(f"PYRO:OpcDaClient@{self.host}:{self.port}")
return opc_da_client_proxy

0 comments on commit 09dc841

Please sign in to comment.