All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] event: Ensure we clean up loggers
@ 2017-11-09 11:56 Richard Purdie
  2017-11-09 11:56 ` [PATCH 2/2] tinfoil: " Richard Purdie
  0 siblings, 1 reply; 2+ messages in thread
From: Richard Purdie @ 2017-11-09 11:56 UTC (permalink / raw)
  To: bitbake-devel

Whilst we're likely exiting in this case, clean up the loggers we add
so that in the case of certain server retries there is no possibility
multiple loggers stack up.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 lib/bb/event.py | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/lib/bb/event.py b/lib/bb/event.py
index 526c41f..52072b5 100644
--- a/lib/bb/event.py
+++ b/lib/bb/event.py
@@ -173,6 +173,10 @@ def print_ui_queue():
             for event in ui_queue[:]:
                 if isinstance(event, logging.LogRecord):
                     logger.handle(event)
+        if msgerrs:
+            logger.removeHandler(stderr)
+        else:
+            logger.removeHandler(stdout)
 
 def fire_ui_handlers(event, d):
     global _thread_lock
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH 2/2] tinfoil: Ensure we clean up loggers
  2017-11-09 11:56 [PATCH 1/2] event: Ensure we clean up loggers Richard Purdie
@ 2017-11-09 11:56 ` Richard Purdie
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Purdie @ 2017-11-09 11:56 UTC (permalink / raw)
  To: bitbake-devel

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.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 lib/bb/tinfoil.py | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/lib/bb/tinfoil.py b/lib/bb/tinfoil.py
index fb2ee4a..fa95f63 100644
--- a/lib/bb/tinfoil.py
+++ b/lib/bb/tinfoil.py
@@ -322,14 +322,14 @@ class Tinfoil:
         self.server_connection = None
         self.recipes_parsed = False
         self.quiet = 0
+        self.oldhandlers = self.logger.handlers[:]
         if setup_logging:
             # This is the *client-side* logger, nothing to do with
             # logging messages from the server
-            oldhandlers = self.logger.handlers[:]
             bb.msg.logger_create('BitBake', output)
             self.localhandlers = []
             for handler in self.logger.handlers:
-                if handler not in oldhandlers:
+                if handler not in self.oldhandlers:
                     self.localhandlers.append(handler)
 
     def __enter__(self):
@@ -835,6 +835,12 @@ class Tinfoil:
             self.server_connection.terminate()
             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):
         """
         Convert an object back to the right type, in the case
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-11-09 11:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-09 11:56 [PATCH 1/2] event: Ensure we clean up loggers Richard Purdie
2017-11-09 11:56 ` [PATCH 2/2] tinfoil: " Richard Purdie

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.