summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/event.py
diff options
context:
space:
mode:
authorChris Larson <chris_larson@mentor.com>2010-09-28 08:24:55 -0700
committerRichard Purdie <rpurdie@linux.intel.com>2011-01-04 14:46:37 +0000
commit26eda933379801ef1c8b4b09e67d14f498cd3813 (patch)
tree16afc923128c95263fde510eaa5d51a73469b5d0 /bitbake/lib/bb/event.py
parent30cef6bade179e88a439ec83ebb78bcc6d041c86 (diff)
downloadpoky-26eda933379801ef1c8b4b09e67d14f498cd3813.tar.gz
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.py21
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
26import warnings 26import warnings
27import pickle 27import pickle
28import logging 28import logging
29import atexit
29import bb.utils 30import bb.utils
30 31
31# This is the pid for which we should generate the event. This is set when 32# 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):
74 h(event) 75 h(event)
75 del event.data 76 del event.data
76 77
78ui_queue = []
79@atexit.register
80def print_ui_queue():
81 """If we're exiting before a UI has been spawned, display any queued
82 LogRecords to the console."""
83 logger = logging.getLogger("BitBake")
84 if not _ui_handlers:
85 console = logging.StreamHandler(sys.stdout)
86 console.setFormatter(logging.Formatter("%(levelname)s: %(message)s"))
87 logger.handlers = [console]
88 while ui_queue:
89 event, d = ui_queue.pop()
90 if isinstance(event, logging.LogRecord):
91 logger.handle(event)
92
77def fire_ui_handlers(event, d): 93def fire_ui_handlers(event, d):
94 if not _ui_handlers:
95 # No UI handlers registered yet, queue up the messages
96 ui_queue.append((event, d))
97 return
98
78 errors = [] 99 errors = []
79 for h in _ui_handlers: 100 for h in _ui_handlers:
80 #print "Sending event %s" % event 101 #print "Sending event %s" % event