gh-95804: Respect MemoryHandler.flushOnClose in logging shutdown. (GH-95857)

This commit is contained in:
David Bonner 2022-08-10 13:08:55 -04:00 committed by GitHub
parent 71c3d649b5
commit 37c0f9ccc0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 37 additions and 1 deletions

View file

@ -2245,7 +2245,11 @@ def shutdown(handlerList=_handlerList):
if h:
try:
h.acquire()
h.flush()
# MemoryHandlers might not want to be flushed on close,
# but circular imports prevent us scoping this to just
# those handlers. hence the default to True.
if getattr(h, 'flushOnClose', True):
h.flush()
h.close()
except (OSError, ValueError):
# Ignore errors which might be caused