From 6dd53d50b713dbb1eaa16d2faa09d1ac86b1b745 Mon Sep 17 00:00:00 2001 From: Chris Withers Date: Wed, 5 Feb 2025 08:32:56 +0000 Subject: [PATCH] Don't attempt to cleanup handlers again if logging.shutdown is called multiple times --- Lib/logging/__init__.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py index aa9b79d8cab4bb..7cb79d5299fb40 100644 --- a/Lib/logging/__init__.py +++ b/Lib/logging/__init__.py @@ -2255,6 +2255,10 @@ def shutdown(handlerList=_handlerList): raise #else, swallow + # Don't attempt to cleanup handlers again if logging.shutdown is called multiple times: + if handlerList is _handlerList: + _handlerList.clear() + #Let's try and shutdown automatically on application exit... import atexit atexit.register(shutdown)