summaryrefslogtreecommitdiffstats
path: root/Lib/logging
diff options
context:
space:
mode:
authorDavid Bonner <dbonner@gmail.com>2022-08-10 17:08:55 (GMT)
committerGitHub <noreply@github.com>2022-08-10 17:08:55 (GMT)
commit37c0f9ccc06750a7e22f5c176df39373f7aca526 (patch)
tree8d86775d55fb448b8e12f608430a50bb879a0b57 /Lib/logging
parent71c3d649b5a0324c6eb01f9ad025c1e102b82bba (diff)
downloadcpython-37c0f9ccc06750a7e22f5c176df39373f7aca526.zip
cpython-37c0f9ccc06750a7e22f5c176df39373f7aca526.tar.gz
cpython-37c0f9ccc06750a7e22f5c176df39373f7aca526.tar.bz2
gh-95804: Respect MemoryHandler.flushOnClose in logging shutdown. (GH-95857)
Diffstat (limited to 'Lib/logging')
-rw-r--r--Lib/logging/__init__.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py
index dc28702..afb5234 100644
--- a/Lib/logging/__init__.py
+++ b/Lib/logging/__init__.py
@@ -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