Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pyro Proxy resource allocation fix #69

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1.Remove invalid context management
2.Improve the example and actively release the connection
Tracersboy committed Dec 11, 2024
commit 09dc841556d6bc126d6729bedf0c7a8f6773d421
2 changes: 2 additions & 0 deletions examples/connect_discover_read_tags.py
Original file line number Diff line number Diff line change
@@ -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__':
8 changes: 4 additions & 4 deletions openopc2/gateway_proxy.py
Original file line number Diff line number Diff line change
@@ -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