diff options
author | Richard Purdie <rpurdie@linux.intel.com> | 2010-03-25 17:33:41 +0000 |
---|---|---|
committer | Richard Purdie <rpurdie@linux.intel.com> | 2010-03-25 17:33:41 +0000 |
commit | d3d36d9f440288fa8bc0901ebefe875fc92409c4 (patch) | |
tree | 9e66cfbc74358070cda8270b098675452e4d65b4 /bitbake/lib/bb/event.py | |
parent | 871f731e5733c27664c4a341cf4b6b0770cb1909 (diff) | |
download | openembedded-core-d3d36d9f440288fa8bc0901ebefe875fc92409c4.tar.gz openembedded-core-d3d36d9f440288fa8bc0901ebefe875fc92409c4.tar.bz2 openembedded-core-d3d36d9f440288fa8bc0901ebefe875fc92409c4.zip |
bitbake/event.py: Run class eventhandlers in the task context but ensure UI handlers run in the server context
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 | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/bitbake/lib/bb/event.py b/bitbake/lib/bb/event.py index b0750e826e..afd5bf57c1 100644 --- a/bitbake/lib/bb/event.py +++ b/bitbake/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""" |