Skip to content

Commit 6b6ad4f

Browse files
authored
Merge pull request #2588 from devitocodes/JDBetteridge/petsc_fix_pytest_log_warning
petsc fix pytest log warning
2 parents 44b4aeb + d06b275 commit 6b6ad4f

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

devito/logger.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,12 @@ def log(msg, level=INFO, *args, **kwargs):
134134
ERROR, CRITICAL``.
135135
"""
136136
color = COLORS[level] if sys.stdout.isatty() and sys.stderr.isatty() else '%s'
137+
# TODO: Think about a proper fix for this:
138+
# When running with PETSc, `PetscFinalize` will helpfully close the stream
139+
# that is being used for logging before all messages are displayed. Specifically
140+
# the operator `info` logging.
141+
if logger.handlers[0] is stream_handler and logger.handlers[0].stream.closed:
142+
logger.handlers[0].stream = sys.stdout
137143
logger.log(level, color % msg, *args, **kwargs)
138144

139145

0 commit comments

Comments
 (0)