[oe-commits] [bitbake] 02/04: event: prevent unclosed file warning in print_ui_queue

git at git.openembedded.org git at git.openembedded.org
Tue Nov 8 23:48:12 UTC 2016


rpurdie pushed a commit to branch 1.30
in repository bitbake.

commit 775888307dc2917ef4b52799cc1600a6b3a01abe
Author: Joshua Lock <joshua.g.lock at intel.com>
AuthorDate: Tue Oct 4 11:03:55 2016 +0100

    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]
    
    Signed-off-by: Joshua Lock <joshua.g.lock at intel.com>
    Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
---
 lib/bb/event.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/bb/event.py b/lib/bb/event.py
index 2cac074..4b133a7 100644
--- a/lib/bb/event.py
+++ b/lib/bb/event.py
@@ -129,16 +129,16 @@ def print_ui_queue():
             if isinstance(event, logging.LogRecord):
                 if event.levelno > logging.DEBUG:
                     if event.levelno >= logging.WARNING:
-                        logger.handlers = [stderr]
+                        logger.addHandler(stderr)
                     else:
-                        logger.handlers = [stdout]
+                        logger.addHandler(stdout)
                     logger.handle(event)
                     msgprint = True
         if msgprint:
             return
 
         # Nope, so just print all of the messages we have (including debug messages)
-        logger.handlers = [stdout]
+        logger.addHandler(stdout)
         for event in ui_queue:
             if isinstance(event, logging.LogRecord):
                 logger.handle(event)

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Openembedded-commits mailing list