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 | |
parent | 871f731e5733c27664c4a341cf4b6b0770cb1909 (diff) | |
download | poky-d3d36d9f440288fa8bc0901ebefe875fc92409c4.tar.gz |
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>
-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 = {} | |||
48 | _ui_handlers = {} | 48 | _ui_handlers = {} |
49 | _ui_handler_seq = 0 | 49 | _ui_handler_seq = 0 |
50 | 50 | ||
51 | def fire(event, d): | 51 | def fire_class_handlers(event, d): |
52 | """Fire off an Event""" | ||
53 | |||
54 | if worker_pid != 0: | ||
55 | worker_fire(event, d) | ||
56 | return | ||
57 | |||
58 | for handler in _handlers: | 52 | for handler in _handlers: |
59 | h = _handlers[handler] | 53 | h = _handlers[handler] |
60 | event.data = d | 54 | event.data = d |
@@ -65,6 +59,7 @@ def fire(event, d): | |||
65 | h(event) | 59 | h(event) |
66 | del event.data | 60 | del event.data |
67 | 61 | ||
62 | def fire_ui_handlers(event, d): | ||
68 | errors = [] | 63 | errors = [] |
69 | for h in _ui_handlers: | 64 | for h in _ui_handlers: |
70 | #print "Sending event %s" % event | 65 | #print "Sending event %s" % event |
@@ -78,6 +73,20 @@ def fire(event, d): | |||
78 | for h in errors: | 73 | for h in errors: |
79 | del _ui_handlers[h] | 74 | del _ui_handlers[h] |
80 | 75 | ||
76 | def fire(event, d): | ||
77 | """Fire off an Event""" | ||
78 | |||
79 | # We can fire class handlers in the worker process context and this is | ||
80 | # desired so they get the task based datastore. | ||
81 | # UI handlers need to be fired in the server context so we defer this. They | ||
82 | # don't have a datastore so the datastore context isn't a problem. | ||
83 | |||
84 | fire_class_handlers(event, d) | ||
85 | if worker_pid != 0: | ||
86 | worker_fire(event, d) | ||
87 | else: | ||
88 | fire_ui_handlers(event, d) | ||
89 | |||
81 | def worker_fire(event, d): | 90 | def worker_fire(event, d): |
82 | data = "<event>" + pickle.dumps(event) + "</event>" | 91 | data = "<event>" + pickle.dumps(event) + "</event>" |
83 | try: | 92 | try: |
@@ -91,7 +100,7 @@ def fire_from_worker(event, d): | |||
91 | print "Error, not an event" | 100 | print "Error, not an event" |
92 | return | 101 | return |
93 | event = pickle.loads(event[7:-8]) | 102 | event = pickle.loads(event[7:-8]) |
94 | bb.event.fire(event, d) | 103 | fire_ui_handlers(event, d) |
95 | 104 | ||
96 | def register(name, handler): | 105 | def register(name, handler): |
97 | """Register an Event handler""" | 106 | """Register an Event handler""" |