summaryrefslogtreecommitdiffstats
path: root/lib/bb/msg.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/bb/msg.py')
-rw-r--r--lib/bb/msg.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/bb/msg.py b/lib/bb/msg.py
index 6259af037..05645739d 100644
--- a/lib/bb/msg.py
+++ b/lib/bb/msg.py
@@ -320,3 +320,14 @@ def setLoggingConfig(defaultconfig, userconfigfile=None):
# TODO: I don't think that setting the global log level should be necessary
#if newlevel < bb.msg.loggerDefaultLogLevel:
# bb.msg.loggerDefaultLogLevel = newlevel
+
+def cleanupLogging():
+ # Iterate through all the handlers and close them if possible. Fixes
+ # 'Unclosed resource' warnings when bitbake exits, see
+ # https://bugs.python.org/issue23010
+ handlers = set()
+ for logger_iter in logging.Logger.manager.loggerDict.keys():
+ handlers.update(logging.getLogger(logger_iter).handlers)
+
+ for h in handlers:
+ h.close()