diff options
author | Joshua Watt <jpewhacker@gmail.com> | 2020-03-11 18:28:44 -0500 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2020-03-13 11:29:23 +0000 |
commit | c8b2694cd4a1fdd93a9bdf727d568ee8530e4039 (patch) | |
tree | f2560de463f229d6481488e5e16802445c9062f7 /bitbake/lib/bb/msg.py | |
parent | 03e35419af773cb742dd18d27b2aaf93ca3cf4e8 (diff) | |
download | poky-c8b2694cd4a1fdd93a9bdf727d568ee8530e4039.tar.gz |
bitbake: knotty: Add logging cleanup
Adds code to close all loggers when bitbake exits. This prevents
unclosed file ResourceWarnings. A form of this closing existed
previously, but was removed in the new logging code.
(Bitbake rev: b3f3779adf63c0d970462a558a6205da1d30c0ed)
Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/msg.py')
-rw-r--r-- | bitbake/lib/bb/msg.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/bitbake/lib/bb/msg.py b/bitbake/lib/bb/msg.py index 6259af037f..05645739d4 100644 --- a/bitbake/lib/bb/msg.py +++ b/bitbake/lib/bb/msg.py | |||
@@ -320,3 +320,14 @@ def setLoggingConfig(defaultconfig, userconfigfile=None): | |||
320 | # TODO: I don't think that setting the global log level should be necessary | 320 | # TODO: I don't think that setting the global log level should be necessary |
321 | #if newlevel < bb.msg.loggerDefaultLogLevel: | 321 | #if newlevel < bb.msg.loggerDefaultLogLevel: |
322 | # bb.msg.loggerDefaultLogLevel = newlevel | 322 | # bb.msg.loggerDefaultLogLevel = newlevel |
323 | |||
324 | def cleanupLogging(): | ||
325 | # Iterate through all the handlers and close them if possible. Fixes | ||
326 | # 'Unclosed resource' warnings when bitbake exits, see | ||
327 | # https://bugs.python.org/issue23010 | ||
328 | handlers = set() | ||
329 | for logger_iter in logging.Logger.manager.loggerDict.keys(): | ||
330 | handlers.update(logging.getLogger(logger_iter).handlers) | ||
331 | |||
332 | for h in handlers: | ||
333 | h.close() | ||