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) |