summaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
authorJoshua Watt <jpewhacker@gmail.com>2020-03-11 18:28:44 -0500
committerRichard Purdie <richard.purdie@linuxfoundation.org>2020-03-13 11:29:23 +0000
commitc8b2694cd4a1fdd93a9bdf727d568ee8530e4039 (patch)
treef2560de463f229d6481488e5e16802445c9062f7 /bitbake
parent03e35419af773cb742dd18d27b2aaf93ca3cf4e8 (diff)
downloadpoky-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')
-rw-r--r--bitbake/lib/bb/msg.py11
-rw-r--r--bitbake/lib/bb/ui/knotty.py2
2 files changed, 13 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
324def 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()
diff --git a/bitbake/lib/bb/ui/knotty.py b/bitbake/lib/bb/ui/knotty.py
index 386f27876d..695108a646 100644
--- a/bitbake/lib/bb/ui/knotty.py
+++ b/bitbake/lib/bb/ui/knotty.py
@@ -823,4 +823,6 @@ def main(server, eventHandler, params, tf = TerminalFilter):
823 if e.errno == errno.EPIPE: 823 if e.errno == errno.EPIPE:
824 pass 824 pass
825 825
826 bb.msg.cleanupLogging()
827
826 return return_value 828 return return_value