[issue33978] logging.config.dictConfig with file handler leaks resources

Géry report at bugs.python.org
Wed Jun 27 05:29:16 EDT 2018


New submission from Géry <gery.ogam at gmail.com>:

Calling logging.config.dictConfig several times with a file handler in the same Python process leaks resources.

INPUT:

$ python3 -Wall <<EOF
import logging.config

config = {
    "version": 1,
    "handlers": {
        "file": {
            "class": "logging.FileHandler",
            "filename": "test.log"
        }
    },
    "root": {
        "handlers": ["file"]
    }
}
logging.config.dictConfig(config)
logging.config.dictConfig(config)
EOF

OUTPUT:

/usr/lib/python3.6/logging/config.py:789: ResourceWarning: unclosed file <_io.TextIOWrapper name='/home/maggyero/test.log' mode='a' encoding='UTF-8'>
  self.common_logger_config(root, config, incremental)

----------
components: Library (Lib)
messages: 320560
nosy: maggyero
priority: normal
severity: normal
status: open
title: logging.config.dictConfig with file handler leaks resources
type: resource usage
versions: Python 3.6

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue33978>
_______________________________________


More information about the Python-bugs-list mailing list