mirror of
https://git.yoctoproject.org/poky
synced 2026-04-17 00:32:13 +02:00
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>
This commit is contained in:
committed by
Richard Purdie
parent
03e35419af
commit
c8b2694cd4
@@ -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()
|
||||
|
||||
@@ -823,4 +823,6 @@ def main(server, eventHandler, params, tf = TerminalFilter):
|
||||
if e.errno == errno.EPIPE:
|
||||
pass
|
||||
|
||||
bb.msg.cleanupLogging()
|
||||
|
||||
return return_value
|
||||
|
||||
Reference in New Issue
Block a user