[bitbake-devel,3/3] bitbake: Use logging.shutdown() instead of bb.msg.cleanupLogging()

Submitted by Joshua Watt on March 12, 2020, 6:30 p.m. | Patch ID: 170995

Details

Message ID 20200312183004.8339-4-JPEWhacker@gmail.com
State New
Headers show

Commit Message

Joshua Watt March 12, 2020, 6:30 p.m.
The logging module provides a shutdown() function that does the same
thing in a much better way

Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
---
 bitbake/lib/bb/msg.py       | 11 -----------
 bitbake/lib/bb/ui/knotty.py |  2 +-
 2 files changed, 1 insertion(+), 12 deletions(-)

Patch hide | download patch | download mbox

diff --git a/bitbake/lib/bb/msg.py b/bitbake/lib/bb/msg.py
index 3f95e21cc1..29f0a3999e 100644
--- a/bitbake/lib/bb/msg.py
+++ b/bitbake/lib/bb/msg.py
@@ -294,14 +294,3 @@  def setLoggingConfig(defaultconfig, userconfigfile=None):
         #    bb.msg.loggerDefaultLogLevel = newlevel
 
     return conf
-
-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()
diff --git a/bitbake/lib/bb/ui/knotty.py b/bitbake/lib/bb/ui/knotty.py
index db4511844a..33ee891256 100644
--- a/bitbake/lib/bb/ui/knotty.py
+++ b/bitbake/lib/bb/ui/knotty.py
@@ -871,6 +871,6 @@  def main(server, eventHandler, params, tf = TerminalFilter):
         if e.errno == errno.EPIPE:
             pass
 
-    bb.msg.cleanupLogging()
+    logging.shutdown()
 
     return return_value