[Python] Unresolved attribute reference 'listener' for class 'Handler'

Discussão em 'Python' iniciado por Stack, Junho 13, 2025.

  1. Stack

    Stack Membro Participativo

    I found this repository, and I'm trying to implement a custom logger into my program using dictConfig(). I created a custom_logger_config.json file and put my config there, also I added a setup_logging method in my main module:

    import atexit
    import json
    import logging.config
    import logging.handlers
    import pathlib

    logger = logging.getLogger("my_program")


    def setup_logging():
    logg_config_file = pathlib.Path("custom_logger_config.json")
    with open(logg_config_file) as f_in:
    config = json.load(f_in)

    logging.config.dictConfig(config)
    queue_handler = logging.getHandlerByName("queue_handler")
    if queue_handler is not None:
    queue_handler.listener.start()
    atexit.register(queue_handler.listener.stop)


    def main():
    setup_logging()
    logging.basicConfig(level="DEBUG")


    I got 2 warnings in my IDE about unresolved attribute reference 'listener' for class 'Handler'. I don't understand where is the problem, because in Python docs class QueueHandler has an attribute listener which was added in Python 3.12 and my project uses Python 3.13.

    Continue reading...

Compartilhe esta Página