summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoshua Lock <joshua.g.lock@intel.com>2016-10-04 11:03:55 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-11-08 23:47:14 +0000
commitbae35b3e5f3f388027cee30dbfc2df8f5a707aba (patch)
tree7c28c37a02afdc71e50190a0d37350f8fc1702ff
parent2de121703d11809d02815e6434674c7ec5e5704c (diff)
downloadpoky-bae35b3e5f3f388027cee30dbfc2df8f5a707aba.tar.gz
bitbake: event: prevent unclosed file warning in print_ui_queue
Use logger.addHandler(), rather than assigning an array of Handlers to the loggers handlers property directly, to avoid a warning from Python 3 about unclosed files: $ bitbake Nothing to do. Use 'bitbake world' to build everything, or run 'bitbake --help' for usage information. WARNING: /home/joshuagl/Projects/poky/bitbake/lib/bb/event.py:143: ResourceWarning: unclosed file <_io.TextIOWrapper name='/home/joshuagl/Projects/poky/build/tmp/log/cooker/qemux86/20161004094928.log' mode='a' encoding='UTF-8'> logger.handlers = [stdout] (Bitbake rev: 775888307dc2917ef4b52799cc1600a6b3a01abe) Signed-off-by: Joshua Lock <joshua.g.lock@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--bitbake/lib/bb/event.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/bitbake/lib/bb/event.py b/bitbake/lib/bb/event.py
index 2cac074a05..4b133a7c12 100644
--- a/bitbake/lib/bb/event.py
+++ b/bitbake/lib/bb/event.py
@@ -129,16 +129,16 @@ def print_ui_queue():
129 if isinstance(event, logging.LogRecord): 129 if isinstance(event, logging.LogRecord):
130 if event.levelno > logging.DEBUG: 130 if event.levelno > logging.DEBUG:
131 if event.levelno >= logging.WARNING: 131 if event.levelno >= logging.WARNING:
132 logger.handlers = [stderr] 132 logger.addHandler(stderr)
133 else: 133 else:
134 logger.handlers = [stdout] 134 logger.addHandler(stdout)
135 logger.handle(event) 135 logger.handle(event)
136 msgprint = True 136 msgprint = True
137 if msgprint: 137 if msgprint:
138 return 138 return
139 139
140 # Nope, so just print all of the messages we have (including debug messages) 140 # Nope, so just print all of the messages we have (including debug messages)
141 logger.handlers = [stdout] 141 logger.addHandler(stdout)
142 for event in ui_queue: 142 for event in ui_queue:
143 if isinstance(event, logging.LogRecord): 143 if isinstance(event, logging.LogRecord):
144 logger.handle(event) 144 logger.handle(event)