Skip to content

Commit

Permalink
Merge branch 'main' into release/0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuelopez-ansys committed May 9, 2024
2 parents 5bc8a45 + 4b1a9e7 commit 2496a4f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
14 changes: 9 additions & 5 deletions examples/toolkit/pyaedt_toolkit/run_toolkit.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@
# Launch backend thread
backend_thread = server_actions(backend_command, "template_backend", is_linux)

# Make a first call to the backend to check the communication
backend_communication_flag = check_backend_communication(url_call)
count = 0
while not backend_communication_flag and count < 10:
backend_communication_flag = check_backend_communication(url_call)
count += 1
if not backend_communication_flag:
raise Exception("Backend communication is not working.")

# Connect to AEDT session if arguments or environment variables are passed
process_desktop_properties(is_linux, url_call)

Expand All @@ -59,10 +68,5 @@
if not backend_flag:
raise Exception("There is a process running in: {}".format(url_call))

# Make a first call to the backend to check the communication
backend_communication_flag = check_backend_communication(url_call)
if not backend_communication_flag:
raise Exception("Backend communication is not working.")

# Keep frontend thread alive until it is closed
frontend_thread.join()
4 changes: 2 additions & 2 deletions src/ansys/aedt/toolkits/common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def check_backend_communication(url_call):
response = requests.get(url_call + "/health")
return response.ok
except requests.exceptions.RequestException:
logger.error("Failed to check backend communication.")
print("Failed to check backend communication.")
return False


Expand Down Expand Up @@ -183,7 +183,7 @@ def process_desktop_properties(is_linux, url_call):
requests.post(url_call + "/launch_aedt")
requests.post(url_call + "/wait_thread")
except requests.exceptions.RequestException:
logger.error("Properties update failed")
raise Exception("Properties update failed.")


class ToolkitThreadStatus(str, Enum):
Expand Down

0 comments on commit 2496a4f

Please sign in to comment.