Skip to content

Commit 1ef31bf

Browse files
FIX: Update gRPC API version check and improve exception handling (#7278)
Co-authored-by: pyansys-ci-bot <92810346+pyansys-ci-bot@users.noreply.github.com>
1 parent 03c7a62 commit 1ef31bf

File tree

8 files changed

+17
-10
lines changed

8 files changed

+17
-10
lines changed

doc/changelog.d/7278.fixed.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Update gRPC API version check and improve exception handling

doc/source/Resources/pyaedt_settings.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ general:
129129
# Skip license check during Desktop initialization
130130
skip_license_check: true
131131
# Enable or disable gRPC API for the EDB module.
132-
# If null, the gRPC API is used if AEDT version is 2026 R1 or later, otherwise the legacy COM object is used.
132+
# If null, the gRPC API is used if AEDT version is above 2026 R1, otherwise the legacy COM object is used.
133133
pyedb_use_grpc: null
134134

135135
grpc:

doc/source/User_guide/settings.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,5 +158,5 @@ Below is the content that can be updated through the YAML file.
158158
# Path to the user defined PyD libraries. If set, it overrides the default pyd_libraries_path
159159
pyd_libraries_user_path: null
160160
# Enable or disable gRPC API for the EDB module.
161-
# If null, the gRPC API is used if AEDT version is 2026 R1 or later, otherwise the legacy COM object is used.
161+
# If null, the gRPC API is used if AEDT version is above 2026 R1, otherwise the legacy COM object is used.
162162
pyedb_use_grpc: null

src/ansys/aedt/core/desktop.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2804,8 +2804,10 @@ def __init_grpc(self):
28042804
is_launched, self.port = launch_aedt(
28052805
installer, self.non_graphical, self.port, self.student_version, host=self.machine
28062806
)
2807+
self.launched_by_pyaedt = True
2808+
28072809
self.new_desktop = not is_launched
2808-
self.launched_by_pyaedt = True
2810+
28092811
# Establish gRPC connection (implementation details)
28102812
result = self.__initialize()
28112813

src/ansys/aedt/core/edb.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,11 @@ def Edb(
124124
else:
125125
settings.aedt_version = aedt_versions.current_version
126126

127-
if settings.pyedb_use_grpc is None and settings.aedt_version > "2025.2": # pragma: no cover
127+
if settings.pyedb_use_grpc is None and settings.aedt_version > "2026.1": # pragma: no cover
128128
settings.logger.info("No EDB gRPC setting provided. Enabling gRPC for EDB.")
129129
settings.pyedb_use_grpc = True
130130

131-
use_grpc = True if settings.pyedb_use_grpc and settings.aedt_version > "2025.2" else False # pragma: no cover
131+
use_grpc = True if settings.pyedb_use_grpc and settings.aedt_version > "2026.1" else False # pragma: no cover
132132
grpc_enabled = "Grpc enabled" if use_grpc else "Dotnet enabled" # pragma: no cover
133133
settings.logger.info(f"Loading EDB with {grpc_enabled}.")
134134

src/ansys/aedt/core/extensions/installer/console_setup.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
from IPython import get_ipython
4141
import tempfile
4242

43+
4344
aedt_process_id = int(os.environ.get("PYAEDT_PROCESS_ID", None)) # pragma: no cover
4445
version = os.environ.get("PYAEDT_DESKTOP_VERSION", None) # pragma: no cover
4546
print("Loading the PyAEDT Console.")
@@ -51,6 +52,8 @@
5152
from ansys.aedt.core.generic.general_methods import active_sessions
5253
from ansys.aedt.core.generic.general_methods import is_windows
5354
from ansys.aedt.core.generic.file_utils import available_file_name
55+
from ansys.aedt.core import settings
56+
settings.release_on_exception = False
5457

5558
except ImportError: # pragma: no cover
5659
# Debug only purpose. If the tool is added to the ribbon from a GitHub clone, then a link
@@ -65,6 +68,8 @@
6568
from ansys.aedt.core.generic.general_methods import active_sessions
6669
from ansys.aedt.core.generic.general_methods import is_windows
6770
from ansys.aedt.core.generic.file_utils import available_file_name
71+
from ansys.aedt.core import settings
72+
settings.release_on_exception = False
6873

6974

7075
def release(d) -> None: # pragma: no cover

src/ansys/aedt/core/extensions/installer/jupyter_template.ipynb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
"from ansys.aedt.core import Desktop\n",
2929
"from ansys.aedt.core import settings\n",
3030
"\n",
31-
"settings.use_grpc_api = True\n"
31+
"settings.use_grpc_api = True\n",
32+
"settings.release_on_exception = False"
3233
]
3334
},
3435
{

src/ansys/aedt/core/generic/general_methods.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,10 +203,8 @@ def raise_exception_or_return_false(e):
203203
from ansys.aedt.core.internal.desktop_sessions import _desktop_sessions
204204

205205
for v in list(_desktop_sessions.values())[:]:
206-
if v.launched_by_pyaedt:
207-
v.close_desktop()
208-
else:
209-
v.release_desktop(False, False)
206+
v.release_desktop(close_projects=v.close_on_exit, close_on_exit=v.close_on_exit)
207+
210208
raise e
211209
elif "__init__" in str(e): # pragma: no cover
212210
return

0 commit comments

Comments
 (0)