1
0
mirror of https://git.yoctoproject.org/poky synced 2026-06-01 00:59:48 +00:00

bitbake: tinfoil: Ensure we clean up loggers

This is primarily paranoid but ensure we remove any loggers we setup
either directly or indirectly so the initial state is restored after
we exit.

(Bitbake rev: 230493d9b99f7d315bc4e5e8d0093bd62ec8f9eb)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit af7d63b1f76fd3f7fa92ed15ae61ca47d9e13472)
Signed-off-by: Armin Kuster <akuster808@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Richard Purdie
2017-11-08 14:04:50 +00:00
parent babf923312
commit 1c61ba0a3f
+8 -2
View File
@@ -322,14 +322,14 @@ class Tinfoil:
self.server_connection = None self.server_connection = None
self.recipes_parsed = False self.recipes_parsed = False
self.quiet = 0 self.quiet = 0
self.oldhandlers = self.logger.handlers[:]
if setup_logging: if setup_logging:
# This is the *client-side* logger, nothing to do with # This is the *client-side* logger, nothing to do with
# logging messages from the server # logging messages from the server
oldhandlers = self.logger.handlers[:]
bb.msg.logger_create('BitBake', output) bb.msg.logger_create('BitBake', output)
self.localhandlers = [] self.localhandlers = []
for handler in self.logger.handlers: for handler in self.logger.handlers:
if handler not in oldhandlers: if handler not in self.oldhandlers:
self.localhandlers.append(handler) self.localhandlers.append(handler)
def __enter__(self): def __enter__(self):
@@ -835,6 +835,12 @@ class Tinfoil:
self.server_connection.terminate() self.server_connection.terminate()
self.server_connection = None self.server_connection = None
# Restore logging handlers to how it looked when we started
if self.oldhandlers:
for handler in self.logger.handlers:
if handler not in self.oldhandlers:
self.logger.handlers.remove(handler)
def _reconvert_type(self, obj, origtypename): def _reconvert_type(self, obj, origtypename):
""" """
Convert an object back to the right type, in the case Convert an object back to the right type, in the case