diff options
Diffstat (limited to 'bitbake/lib')
-rw-r--r-- | bitbake/lib/bb/event.py | 21 | ||||
-rw-r--r-- | bitbake/lib/toaster/tests/functional/README | 0 |
2 files changed, 21 insertions, 0 deletions
diff --git a/bitbake/lib/bb/event.py b/bitbake/lib/bb/event.py index 42745e241e..65b7ebb43b 100644 --- a/bitbake/lib/bb/event.py +++ b/bitbake/lib/bb/event.py | |||
@@ -29,6 +29,8 @@ import logging | |||
29 | import atexit | 29 | import atexit |
30 | import traceback | 30 | import traceback |
31 | import ast | 31 | import ast |
32 | import threading | ||
33 | |||
32 | import bb.utils | 34 | import bb.utils |
33 | import bb.compat | 35 | import bb.compat |
34 | import bb.exceptions | 36 | import bb.exceptions |
@@ -68,12 +70,22 @@ _event_handler_map = {} | |||
68 | _catchall_handlers = {} | 70 | _catchall_handlers = {} |
69 | _eventfilter = None | 71 | _eventfilter = None |
70 | _uiready = False | 72 | _uiready = False |
73 | _thread_lock = threading.Lock() | ||
74 | _thread_lock_enabled = False | ||
71 | 75 | ||
72 | if hasattr(__builtins__, '__setitem__'): | 76 | if hasattr(__builtins__, '__setitem__'): |
73 | builtins = __builtins__ | 77 | builtins = __builtins__ |
74 | else: | 78 | else: |
75 | builtins = __builtins__.__dict__ | 79 | builtins = __builtins__.__dict__ |
76 | 80 | ||
81 | def enable_threadlock(): | ||
82 | global _thread_lock_enabled | ||
83 | _thread_lock_enabled = True | ||
84 | |||
85 | def disable_threadlock(): | ||
86 | global _thread_lock_enabled | ||
87 | _thread_lock_enabled = False | ||
88 | |||
77 | def execute_handler(name, handler, event, d): | 89 | def execute_handler(name, handler, event, d): |
78 | event.data = d | 90 | event.data = d |
79 | addedd = False | 91 | addedd = False |
@@ -146,11 +158,17 @@ def print_ui_queue(): | |||
146 | logger.handle(event) | 158 | logger.handle(event) |
147 | 159 | ||
148 | def fire_ui_handlers(event, d): | 160 | def fire_ui_handlers(event, d): |
161 | global _thread_lock | ||
162 | global _thread_lock_enabled | ||
163 | |||
149 | if not _uiready: | 164 | if not _uiready: |
150 | # No UI handlers registered yet, queue up the messages | 165 | # No UI handlers registered yet, queue up the messages |
151 | ui_queue.append(event) | 166 | ui_queue.append(event) |
152 | return | 167 | return |
153 | 168 | ||
169 | if _thread_lock_enabled: | ||
170 | _thread_lock.acquire() | ||
171 | |||
154 | errors = [] | 172 | errors = [] |
155 | for h in _ui_handlers: | 173 | for h in _ui_handlers: |
156 | #print "Sending event %s" % event | 174 | #print "Sending event %s" % event |
@@ -169,6 +187,9 @@ def fire_ui_handlers(event, d): | |||
169 | for h in errors: | 187 | for h in errors: |
170 | del _ui_handlers[h] | 188 | del _ui_handlers[h] |
171 | 189 | ||
190 | if _thread_lock_enabled: | ||
191 | _thread_lock.release() | ||
192 | |||
172 | def fire(event, d): | 193 | def fire(event, d): |
173 | """Fire off an Event""" | 194 | """Fire off an Event""" |
174 | 195 | ||
diff --git a/bitbake/lib/toaster/tests/functional/README b/bitbake/lib/toaster/tests/functional/README new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/bitbake/lib/toaster/tests/functional/README | |||