Fix error in test suite teardown

The error seen was:

Exception ignored in atexit callback: <bound method DeferredStreamHandler.flush of <DeferredStreamHandler <_io.FileIO [closed]> (WARNING)>>
Traceback (most recent call last):
  File "/home/dan/src/salt/salt/_logging/handlers.py", line 68, in flush
    super().flush()
  File "/usr/local/lib/python3.10/logging/__init__.py", line 1084, in flush
    self.stream.flush()
ValueError: I/O operation on closed file.
This commit is contained in:
Daniel A. Wozniak 2024-09-22 15:10:36 -07:00 committed by Daniel Wozniak
parent d11775eeca
commit 64690a935c

View file

@ -65,7 +65,11 @@ class DeferredStreamHandler(StreamHandler):
super().handle(record)
finally:
self.__emitting = False
super().flush()
# Seeing an exception from calling flush on a closed file in the test
# suite. Handling this condition for now but this seems to be
# indicitive of an un-clean teardown at some point.
if not self.stream.closed:
super().flush()
def sync_with_handlers(self, handlers=()):
"""