aboutsummaryrefslogtreecommitdiffstats
path: root/lib/bb/event.py
diff options
context:
space:
mode:
authorRichard Purdie <rpurdie@linux.intel.com>2010-03-25 17:33:41 +0000
committerRichard Purdie <rpurdie@linux.intel.com>2010-03-25 17:33:59 +0000
commitb32f9759550dae02ca6e618050059a8deac6c650 (patch)
treea4ca5b28470bb681c5ae227898cd499a5732a0c4 /lib/bb/event.py
parentacc27c3988b58e5a4709d547c03936c9846dcc08 (diff)
downloadbitbake-b32f9759550dae02ca6e618050059a8deac6c650.tar.gz
bitbake-b32f9759550dae02ca6e618050059a8deac6c650.tar.bz2
bitbake-b32f9759550dae02ca6e618050059a8deac6c650.zip
bitbake/event.py: Run class eventhandlers in the task context but ensure UI handlers run in the server context
(From Poky rev: d3d36d9f440288fa8bc0901ebefe875fc92409c4) Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
Diffstat (limited to 'lib/bb/event.py')
-rw-r--r--lib/bb/event.py25
1 files changed, 17 insertions, 8 deletions
diff --git a/lib/bb/event.py b/lib/bb/event.py
index b0750e82..afd5bf57 100644
--- a/lib/bb/event.py
+++ b/lib/bb/event.py
@@ -48,13 +48,7 @@ _handlers = {}
_ui_handlers = {}
_ui_handler_seq = 0
-def fire(event, d):
- """Fire off an Event"""
-
- if worker_pid != 0:
- worker_fire(event, d)
- return
-
+def fire_class_handlers(event, d):
for handler in _handlers:
h = _handlers[handler]
event.data = d
@@ -65,6 +59,7 @@ def fire(event, d):
h(event)
del event.data
+def fire_ui_handlers(event, d):
errors = []
for h in _ui_handlers:
#print "Sending event %s" % event
@@ -78,6 +73,20 @@ def fire(event, d):
for h in errors:
del _ui_handlers[h]
+def fire(event, d):
+ """Fire off an Event"""
+
+ # We can fire class handlers in the worker process context and this is
+ # desired so they get the task based datastore.
+ # UI handlers need to be fired in the server context so we defer this. They
+ # don't have a datastore so the datastore context isn't a problem.
+
+ fire_class_handlers(event, d)
+ if worker_pid != 0:
+ worker_fire(event, d)
+ else:
+ fire_ui_handlers(event, d)
+
def worker_fire(event, d):
data = "<event>" + pickle.dumps(event) + "</event>"
try:
@@ -91,7 +100,7 @@ def fire_from_worker(event, d):
print "Error, not an event"
return
event = pickle.loads(event[7:-8])
- bb.event.fire(event, d)
+ fire_ui_handlers(event, d)
def register(name, handler):
"""Register an Event handler"""