diff options
author | Chris Larson <chris_larson@mentor.com> | 2010-09-28 08:24:55 -0700 |
---|---|---|
committer | Richard Purdie <rpurdie@linux.intel.com> | 2011-01-04 14:46:37 +0000 |
commit | 26eda933379801ef1c8b4b09e67d14f498cd3813 (patch) | |
tree | 16afc923128c95263fde510eaa5d51a73469b5d0 /bitbake/lib/bb/event.py | |
parent | 30cef6bade179e88a439ec83ebb78bcc6d041c86 (diff) | |
download | openembedded-core-26eda933379801ef1c8b4b09e67d14f498cd3813.tar.gz openembedded-core-26eda933379801ef1c8b4b09e67d14f498cd3813.tar.bz2 openembedded-core-26eda933379801ef1c8b4b09e67d14f498cd3813.zip |
Queue up events before the UI is spawned
- Queue up any events fired to the UI before the UI exists
- At exit, check if UIs exist, and if not, flush the queue of LogRecords to
the console directly.
- When establishing a connection from the UI to the server, flush the queue of
events to the queue in the server connection, so the UI will receive them
when it begins its event loop.
(Bitbake rev: 73488aeb317ed306f2ecf99cc9d3708526a5933c)
Signed-off-by: Chris Larson <chris_larson@mentor.com>
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
Diffstat (limited to 'bitbake/lib/bb/event.py')
-rw-r--r-- | bitbake/lib/bb/event.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/bitbake/lib/bb/event.py b/bitbake/lib/bb/event.py index f3efae9bdf..fb355089a3 100644 --- a/bitbake/lib/bb/event.py +++ b/bitbake/lib/bb/event.py @@ -26,6 +26,7 @@ import os, sys import warnings import pickle import logging +import atexit import bb.utils # This is the pid for which we should generate the event. This is set when @@ -74,7 +75,27 @@ def fire_class_handlers(event, d): h(event) del event.data +ui_queue = [] +@atexit.register +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: + console = logging.StreamHandler(sys.stdout) + console.setFormatter(logging.Formatter("%(levelname)s: %(message)s")) + logger.handlers = [console] + while ui_queue: + event, d = ui_queue.pop() + if isinstance(event, logging.LogRecord): + logger.handle(event) + def fire_ui_handlers(event, d): + if not _ui_handlers: + # No UI handlers registered yet, queue up the messages + ui_queue.append((event, d)) + return + errors = [] for h in _ui_handlers: #print "Sending event %s" % event |