Skip to content

Commit

Permalink
Merge branch 'main' into fix/changing-entities-ids-after-plotting
Browse files Browse the repository at this point in the history
  • Loading branch information
germa89 authored Sep 24, 2024
2 parents b44e375 + 8298793 commit 065b691
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions doc/changelog.d/3428.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fix: disabling logging on `__del__`
8 changes: 5 additions & 3 deletions src/ansys/mapdl/core/mapdl_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -2279,7 +2279,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()
Expand All @@ -2293,10 +2294,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:
Expand Down

0 comments on commit 065b691

Please sign in to comment.