Skip to content

Improved the way client connection is checked. Added mono cleanup dis… #794

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

Merged
merged 1 commit into from
Jan 31, 2022
Merged
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
15 changes: 12 additions & 3 deletions pyaedt/common_rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ def launch_server(port=18000, ansysem_path=None, non_graphical=False):
if os.name == "posix":
os.environ["PYAEDT_SERVER_AEDT_PATH"] = ansysem_path
os.environ["PYAEDT_SERVER_AEDT_NG"] = str(non_graphical)
os.environ["ANS_NO_MONO_CLEANUP"] = str(1)

hostname = socket.gethostname()
safe_attrs = {
"__abs__",
Expand Down Expand Up @@ -219,7 +221,15 @@ def client(server_name, server_port=18000, beta_options=None):
>>> cl2.root.run_script(script_to_run, ansysem_path = "/path/to/AnsysEMxxx/Linux64")

"""
c = rpyc.connect(server_name, server_port, config={"sync_request_timeout": None})
t = 20
while t > 0:
try:
c = rpyc.connect(server_name, server_port, config={"sync_request_timeout": None})
if c.root:
t = 0
except:
t -= 1
time.sleep(1)
port = c.root.start_service(server_name, beta_options)
if not port:
return "Error Connecting to the Server. Check the server name and port and retry."
Expand Down Expand Up @@ -374,8 +384,7 @@ def launch_ironpython_server(aedt_path, non_graphical=False, port=18000, launch_
print("Process {} started on {}".format(proc.pid, socket.getfqdn()))
print("Warning: Remote CPython to Ironpython may have some limitations.")
print("Known Issues are on returned list and dict. ")
print("For those it is recommended to use client.conver_remote_object method.")
time.sleep(5)
print("For those it is recommended to use client.convert_remote_object method.")
if proc and launch_client:
return client(server_name=socket.getfqdn(), server_port=port)
return False