From d5dcd64ed8bf95adfd08451f26338ed920e7b8e1 Mon Sep 17 00:00:00 2001 From: Aaron LI Date: Sun, 2 Oct 2016 20:32:32 +0800 Subject: utils/logging.py: Close handler before removing --- fg21sim/utils/logging.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'fg21sim') diff --git a/fg21sim/utils/logging.py b/fg21sim/utils/logging.py index df0a4df..bc827fc 100644 --- a/fg21sim/utils/logging.py +++ b/fg21sim/utils/logging.py @@ -48,6 +48,7 @@ def setup_logging(dict_config=None, level=None, stream=None, logfile=None): # Clear existing handlers, otherwise further "basicConfig" calls # will be ignored for handler in root_logger.handlers: + handler.close() root_logger.removeHandler(handler) # Initialize/reconfigure the logging, which will automatically # create a ``Formatter`` for handlers if necessary, and adding @@ -69,6 +70,7 @@ def setup_logging(dict_config=None, level=None, stream=None, logfile=None): for handler in root_logger.handlers: if isinstance(handler, StreamHandler): # remove old ``StreamHandler`` + handler.close() root_logger.removeHandler(handler) if stream == "": # disable ``StreamHandler`` @@ -86,6 +88,7 @@ def setup_logging(dict_config=None, level=None, stream=None, logfile=None): if isinstance(handler, FileHandler): filemode = handler.mode # remove old ``FileHandler`` + handler.close() root_logger.removeHandler(handler) if logfile == "": # disable ``FileHandler`` -- cgit v1.2.2