summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2017-11-08 14:04:50 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-11-09 12:24:40 +0000
commita87cae5bb1b0168b29eef7076756ef1d7179ee72 (patch)
tree2fe394f02d0c97ae9f19d0c579671a2dfef9ac43
parenta04ee42393822158e5aa6c181d90e1f45dab8c62 (diff)
downloadpoky-a87cae5bb1b0168b29eef7076756ef1d7179ee72.tar.gz
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: af7d63b1f76fd3f7fa92ed15ae61ca47d9e13472) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--bitbake/lib/bb/tinfoil.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/bitbake/lib/bb/tinfoil.py b/bitbake/lib/bb/tinfoil.py
index fb2ee4ad9c..fa95f6329f 100644
--- a/bitbake/lib/bb/tinfoil.py
+++ b/bitbake/lib/bb/tinfoil.py
@@ -322,14 +322,14 @@ class Tinfoil:
322 self.server_connection = None 322 self.server_connection = None
323 self.recipes_parsed = False 323 self.recipes_parsed = False
324 self.quiet = 0 324 self.quiet = 0
325 self.oldhandlers = self.logger.handlers[:]
325 if setup_logging: 326 if setup_logging:
326 # This is the *client-side* logger, nothing to do with 327 # This is the *client-side* logger, nothing to do with
327 # logging messages from the server 328 # logging messages from the server
328 oldhandlers = self.logger.handlers[:]
329 bb.msg.logger_create('BitBake', output) 329 bb.msg.logger_create('BitBake', output)
330 self.localhandlers = [] 330 self.localhandlers = []
331 for handler in self.logger.handlers: 331 for handler in self.logger.handlers:
332 if handler not in oldhandlers: 332 if handler not in self.oldhandlers:
333 self.localhandlers.append(handler) 333 self.localhandlers.append(handler)
334 334
335 def __enter__(self): 335 def __enter__(self):
@@ -835,6 +835,12 @@ class Tinfoil:
835 self.server_connection.terminate() 835 self.server_connection.terminate()
836 self.server_connection = None 836 self.server_connection = None
837 837
838 # Restore logging handlers to how it looked when we started
839 if self.oldhandlers:
840 for handler in self.logger.handlers:
841 if handler not in self.oldhandlers:
842 self.logger.handlers.remove(handler)
843
838 def _reconvert_type(self, obj, origtypename): 844 def _reconvert_type(self, obj, origtypename):
839 """ 845 """
840 Convert an object back to the right type, in the case 846 Convert an object back to the right type, in the case