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: