All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] event/server: Add _uiready flag to handle missing error messages
@ 2015-09-03 14:20 Richard Purdie
  2015-09-03 17:54 ` Christopher Larson
  0 siblings, 1 reply; 2+ messages in thread
From: Richard Purdie @ 2015-09-03 14:20 UTC (permalink / raw)
  To: bitbake-devel

If you start and suspend a bitbake execution so the bitbake lock is held,
then try and run "bitbake -w '' X", you will see bitbake return an error exit
code but print no message about what happened at all.

The reason is that the -w option creates a "UI" which swallows the messages. The
code which handles this exit failure mode thinks a UI has printed the messages
and therefore doesn't do so.

This adds in an extra parameter to the UI registration code so that we
can figure out whether its a primary UI or not and base decisions on whether
to display information on that instead. This fixes the error shown above and
some bizarre failures on the Yocto Project Autobuilder.

[YOCTO #8239]

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>

diff --git a/bitbake/lib/bb/event.py b/bitbake/lib/bb/event.py
index da20fbf..059229e 100644
--- a/bitbake/lib/bb/event.py
+++ b/bitbake/lib/bb/event.py
@@ -69,6 +69,7 @@ _ui_handler_seq = 0
 _event_handler_map = {}
 _catchall_handlers = {}
 _eventfilter = None
+_uiready = False
 
 def execute_handler(name, handler, event, d):
     event.data = d
@@ -113,7 +117,7 @@ def print_ui_queue():
     """If we're exiting before a UI has been spawned, display any queued
     LogRecords to the console."""
     logger = logging.getLogger("BitBake")
-    if not _ui_handlers:
+    if not _uiready:
         from bb.msg import BBLogFormatter
         console = logging.StreamHandler(sys.stdout)
         console.setFormatter(BBLogFormatter("%(levelname)s: %(message)s"))
@@ -135,7 +139,7 @@ def print_ui_queue():
                 logger.handle(event)
 
 def fire_ui_handlers(event, d):
-    if not _ui_handlers:
+    if not _uiready:
         # No UI handlers registered yet, queue up the messages
         ui_queue.append(event)
         return
@@ -219,7 +223,9 @@ def set_eventfilter(func):
     global _eventfilter
     _eventfilter = func
 
-def register_UIHhandler(handler):
+def register_UIHhandler(handler, mainui=False):
+    if mainui:
+        _uiready = True
     bb.event._ui_handler_seq = bb.event._ui_handler_seq + 1
     _ui_handlers[_ui_handler_seq] = handler
     level, debug_domains = bb.msg.constructLogOptions()
diff --git a/bitbake/lib/bb/server/process.py b/bitbake/lib/bb/server/process.py
index 3198635..f022b86 100644
--- a/bitbake/lib/bb/server/process.py
+++ b/bitbake/lib/bb/server/process.py
@@ -97,7 +97,7 @@ class ProcessServer(Process, BaseImplServer):
     def run(self):
         for event in bb.event.ui_queue:
             self.event_queue.put(event)
-        self.event_handle.value = bb.event.register_UIHhandler(self)
+        self.event_handle.value = bb.event.register_UIHhandler(self, True)
 
         bb.cooker.server_main(self.cooker, self.main)
 
diff --git a/bitbake/lib/bb/server/xmlrpc.py b/bitbake/lib/bb/server/xmlrpc.py
index f1a2067..b7647c1 100644
--- a/bitbake/lib/bb/server/xmlrpc.py
+++ b/bitbake/lib/bb/server/xmlrpc.py
@@ -99,7 +99,7 @@ class BitBakeServerCommands():
         if (self.cooker.state in [bb.cooker.state.parsing, bb.cooker.state.running]):
             return None
 
-        self.event_handle = bb.event.register_UIHhandler(s)
+        self.event_handle = bb.event.register_UIHhandler(s, True)
         return self.event_handle
 
     def unregisterEventHandler(self, handlerNum):




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

* Re: [PATCH] event/server: Add _uiready flag to handle missing error messages
  2015-09-03 14:20 [PATCH] event/server: Add _uiready flag to handle missing error messages Richard Purdie
@ 2015-09-03 17:54 ` Christopher Larson
  0 siblings, 0 replies; 2+ messages in thread
From: Christopher Larson @ 2015-09-03 17:54 UTC (permalink / raw)
  To: Richard Purdie; +Cc: bitbake-devel

[-- Attachment #1: Type: text/plain, Size: 1005 bytes --]

On Thu, Sep 3, 2015 at 7:20 AM, Richard Purdie <
richard.purdie@linuxfoundation.org> wrote:

> -        self.event_handle = bb.event.register_UIHhandler(s)
> +        self.event_handle = bb.event.register_UIHhandler(s, True)
>

Minor quibble: when using positional arguments of this sort, directly,
without an intermediate variable, when reading it, it's not clear what the
argument is doing. Admittedly, we do this all the time with getVar(), but
really that was a crappy API to begin with :) The code becomes a bit more
readable if you pass the argument name as though it was a keyword argument,
so we have context when reading it, e.g.:

    self.event_handle = bb.event.register_UIHhandler(s, mainui=True)

Obviously, this is relatively minor, so shouldn't block a merge, but it's
something to keep in mind going forward.
-- 
Christopher Larson
clarson at kergoth dot com
Founder - BitBake, OpenEmbedded, OpenZaurus
Maintainer - Tslib
Senior Software Engineer, Mentor Graphics

[-- Attachment #2: Type: text/html, Size: 1576 bytes --]

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

end of thread, other threads:[~2015-09-03 17:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-03 14:20 [PATCH] event/server: Add _uiready flag to handle missing error messages Richard Purdie
2015-09-03 17:54 ` Christopher Larson

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.