Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: disabling logging on __del__ #3428

Merged
merged 5 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -2280,7 +2280,8 @@
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)

Check warning on line 2284 in src/ansys/mapdl/core/mapdl_core.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/mapdl/core/mapdl_core.py#L2284

Added line #L2284 was not covered by tests

try:
self.exit()
Expand All @@ -2294,10 +2295,11 @@
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
Loading