From 0207fd08250e6ee81996e80524078d2e8f5f73d9 Mon Sep 17 00:00:00 2001 From: github-actions Date: Mon, 28 Oct 2024 17:16:30 -0400 Subject: [PATCH] stop logger on exit --- bbot/core/config/logger.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/bbot/core/config/logger.py b/bbot/core/config/logger.py index 4723d4237c..10cdd7b2ec 100644 --- a/bbot/core/config/logger.py +++ b/bbot/core/config/logger.py @@ -1,9 +1,11 @@ import sys +import atexit import logging from copy import copy import multiprocessing import logging.handlers from pathlib import Path +from contextlib import suppress from ..helpers.misc import mkdir, error_and_exit from ...logger import colorize, loglevel_mapping @@ -70,9 +72,14 @@ def __init__(self, core): # Start the QueueListener self.listener = logging.handlers.QueueListener(self.queue, *self.log_handlers.values()) self.listener.start() + atexit.register(self.listener.stop) self.log_level = logging.INFO + def stop_listener(self): + with suppress(Exception): + self.listener.stop() + def setup_queue_handler(self, logging_queue=None, log_level=logging.DEBUG): if logging_queue is None: logging_queue = self.queue