From 82987933a111721b9a33ec42b7aa2f03a54d0ca8 Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Mon, 23 Sep 2024 19:07:17 +0200 Subject: [PATCH] fix: disabling logging on `__del__` (#3428) * fix: disabling logging on __del__ * chore: adding changelog file 3428.fixed.md * test: avoiding early exit * feat: testing disable * empty commit --------- Co-authored-by: pyansys-ci-bot <92810346+pyansys-ci-bot@users.noreply.github.com> --- doc/changelog.d/3428.fixed.md | 1 + src/ansys/mapdl/core/mapdl_core.py | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) create mode 100644 doc/changelog.d/3428.fixed.md diff --git a/doc/changelog.d/3428.fixed.md b/doc/changelog.d/3428.fixed.md new file mode 100644 index 0000000000..809dcba3f1 --- /dev/null +++ b/doc/changelog.d/3428.fixed.md @@ -0,0 +1 @@ +fix: disabling logging on `__del__` \ No newline at end of file diff --git a/src/ansys/mapdl/core/mapdl_core.py b/src/ansys/mapdl/core/mapdl_core.py index e4502ece48..c11430d38d 100644 --- a/src/ansys/mapdl/core/mapdl_core.py +++ b/src/ansys/mapdl/core/mapdl_core.py @@ -2280,7 +2280,8 @@ def __del__(self): if self._cleanup: # removing logging handlers if they are closed to avoid I/O errors # when exiting after the logger file has been closed. - self._cleanup_loggers() + # self._cleanup_loggers() + logging.disable(logging.CRITICAL) try: self.exit() @@ -2294,10 +2295,11 @@ def __del__(self): def _cleanup_loggers(self): """Clean up all the loggers""" # Detached from ``__del__`` for easier testing - if not hasattr(self, "_log"): - return # Early exit if logger has been already cleaned. + # if not hasattr(self, "_log"): + # return # Early exit if logger has been already cleaned. logger = self._log + logger.setLevel(logging.CRITICAL + 1) if logger.hasHandlers(): for each_handler in logger.logger.handlers: