From a6423bfd63d56436f66e5e18035535d146c18329 Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Thu, 12 Dec 2024 13:17:50 +0100 Subject: [PATCH 1/6] fix: ending routine and going into verify mode when exiting. Also change function name --- src/ansys/mapdl/core/mapdl_grpc.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/ansys/mapdl/core/mapdl_grpc.py b/src/ansys/mapdl/core/mapdl_grpc.py index 0ebd1618c3..9d959c17a2 100644 --- a/src/ansys/mapdl/core/mapdl_grpc.py +++ b/src/ansys/mapdl/core/mapdl_grpc.py @@ -1187,12 +1187,13 @@ def _exit_mapdl(self, path: str = None) -> None: if self._local: self._cache_pids() # Recache processes - if os.name == "nt": - self._kill_server() + self._exit_mapdl_server() + self._close_process() + self._remove_lock_file(path) else: - self._kill_server() + self._exit_mapdl_server() def _remove_temp_dir_on_exit(self, path=None): """Removes the temporary directory created by the launcher. @@ -1218,7 +1219,7 @@ def _remove_temp_dir_on_exit(self, path=None): tmp_dir, ) - def _kill_server(self): + def _exit_mapdl_server(self): """Call exit(0) on the server. Notes @@ -1231,6 +1232,9 @@ def _kill_server(self): if self._exited: return + self.finish() + self.verify() # to avoid issues while parsing + if ( self._version and self._version >= 24.2 ): # We can't use the non-cached version because of recursion error. @@ -1287,15 +1291,12 @@ def _close_process(self, timeout=2): # pragma: no cover Notes ----- This is effectively the only way to completely close down MAPDL locally on - linux. Just killing the server with ``_kill_server`` leaves orphaned + linux. Just killing the server with ``_exit_mapdl_server`` leaves orphaned processes making this method ineffective for a local instance of MAPDL. """ self._log.debug("Closing processes") if self._local: - # killing server process - self._kill_server() - # killing main process (subprocess) self._kill_process() From da1a473625a72d34d35a8d786ec46d43b8ce4f80 Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Thu, 12 Dec 2024 13:18:39 +0100 Subject: [PATCH 2/6] docs: better comment --- src/ansys/mapdl/core/mapdl_grpc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ansys/mapdl/core/mapdl_grpc.py b/src/ansys/mapdl/core/mapdl_grpc.py index 9d959c17a2..ddfe97b7b5 100644 --- a/src/ansys/mapdl/core/mapdl_grpc.py +++ b/src/ansys/mapdl/core/mapdl_grpc.py @@ -1233,7 +1233,7 @@ def _exit_mapdl_server(self): return self.finish() - self.verify() # to avoid issues while parsing + self.verify() # to avoid issues on the gRPC interface if ( self._version and self._version >= 24.2 From ac7b97e637fb46d1fc05a39c826b715f5eefded9 Mon Sep 17 00:00:00 2001 From: pyansys-ci-bot <92810346+pyansys-ci-bot@users.noreply.github.com> Date: Thu, 12 Dec 2024 12:21:45 +0000 Subject: [PATCH 3/6] chore: adding changelog file 3617.fixed.md [dependabot-skip] --- doc/changelog.d/3617.fixed.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 doc/changelog.d/3617.fixed.md diff --git a/doc/changelog.d/3617.fixed.md b/doc/changelog.d/3617.fixed.md new file mode 100644 index 0000000000..5b665a9eb3 --- /dev/null +++ b/doc/changelog.d/3617.fixed.md @@ -0,0 +1 @@ +fix: exit getting frozen if routine is not finished \ No newline at end of file From 2308919f8dd3ef2f8fbba7144572c5d6f079130b Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Thu, 12 Dec 2024 13:28:54 +0100 Subject: [PATCH 4/6] refactor: not issuing verify anymore --- src/ansys/mapdl/core/mapdl_grpc.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/ansys/mapdl/core/mapdl_grpc.py b/src/ansys/mapdl/core/mapdl_grpc.py index ddfe97b7b5..42686f7159 100644 --- a/src/ansys/mapdl/core/mapdl_grpc.py +++ b/src/ansys/mapdl/core/mapdl_grpc.py @@ -1232,13 +1232,11 @@ def _exit_mapdl_server(self): if self._exited: return - self.finish() - self.verify() # to avoid issues on the gRPC interface - if ( self._version and self._version >= 24.2 ): # We can't use the non-cached version because of recursion error. # self.run("/EXIT,NOSAVE,,,,,SERVER") + self.finish() self._ctrl("EXIT") else: self._ctrl("EXIT") From b613cb6a40d5459bb71f781d77b790985788e3ba Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Thu, 12 Dec 2024 16:47:41 +0100 Subject: [PATCH 5/6] refactor: _exit_mapdl_server branching --- src/ansys/mapdl/core/mapdl_grpc.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/ansys/mapdl/core/mapdl_grpc.py b/src/ansys/mapdl/core/mapdl_grpc.py index 42686f7159..38cc36481c 100644 --- a/src/ansys/mapdl/core/mapdl_grpc.py +++ b/src/ansys/mapdl/core/mapdl_grpc.py @@ -1232,15 +1232,21 @@ def _exit_mapdl_server(self): if self._exited: return - if ( - self._version and self._version >= 24.2 - ): # We can't use the non-cached version because of recursion error. + # Default + if self._version is None or self._version < 24.1: + self._ctrl("EXIT") + + elif self._version >= 25.1: + # We can't use the non-cached version because of recursion error. # self.run("/EXIT,NOSAVE,,,,,SERVER") self.finish() self._ctrl("EXIT") - else: + + elif self._version >= 24.1: self._ctrl("EXIT") + return + def _kill_process(self): """Kill process stored in self._mapdl_process""" if self._mapdl_process is not None: From 454b075276206ab911e2eb8eeb5402fada66c448 Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Thu, 12 Dec 2024 17:12:18 +0100 Subject: [PATCH 6/6] refactor: finishing routine for v24.1 or older --- src/ansys/mapdl/core/mapdl_grpc.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/ansys/mapdl/core/mapdl_grpc.py b/src/ansys/mapdl/core/mapdl_grpc.py index 38cc36481c..a0b2cecc66 100644 --- a/src/ansys/mapdl/core/mapdl_grpc.py +++ b/src/ansys/mapdl/core/mapdl_grpc.py @@ -1236,15 +1236,12 @@ def _exit_mapdl_server(self): if self._version is None or self._version < 24.1: self._ctrl("EXIT") - elif self._version >= 25.1: + elif self._version >= 24.1: # We can't use the non-cached version because of recursion error. # self.run("/EXIT,NOSAVE,,,,,SERVER") self.finish() self._ctrl("EXIT") - elif self._version >= 24.1: - self._ctrl("EXIT") - return def _kill_process(self):