[gnome-continuous-yocto/gnomeostree-3.28-rocko: 2864/8267] bitbake: bb/event.py: fire_ui_handlers enable threading lock support
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-continuous-yocto/gnomeostree-3.28-rocko: 2864/8267] bitbake: bb/event.py: fire_ui_handlers enable threading lock support
- Date: Sat, 16 Dec 2017 23:49:41 +0000 (UTC)
commit 79012f943d3b3af1f439022f05a1287a383cd3f8
Author: Aníbal Limón <anibal limon linux intel com>
Date: Tue Oct 4 16:15:56 2016 -0500
bitbake: bb/event.py: fire_ui_handlers enable threading lock support
In some cases there is a need to fire bb events into multiple
python threads so locking is needed (writing to a fd/socket).
Adding a helper functions for disable/enable by request to avoid
overhead.
[YOCTO #10330]
(Bitbake rev: a583dc0b296415ec904c081c4de96ceef46732a8)
Signed-off-by: Aníbal Limón <anibal limon linux intel com>
Signed-off-by: Richard Purdie <richard purdie linuxfoundation org>
bitbake/lib/bb/event.py | 21 +++++++++++++++++++++
1 files changed, 21 insertions(+), 0 deletions(-)
---
diff --git a/bitbake/lib/bb/event.py b/bitbake/lib/bb/event.py
index 42745e2..65b7ebb 100644
--- a/bitbake/lib/bb/event.py
+++ b/bitbake/lib/bb/event.py
@@ -29,6 +29,8 @@ import logging
import atexit
import traceback
import ast
+import threading
+
import bb.utils
import bb.compat
import bb.exceptions
@@ -68,12 +70,22 @@ _event_handler_map = {}
_catchall_handlers = {}
_eventfilter = None
_uiready = False
+_thread_lock = threading.Lock()
+_thread_lock_enabled = False
if hasattr(__builtins__, '__setitem__'):
builtins = __builtins__
else:
builtins = __builtins__.__dict__
+def enable_threadlock():
+ global _thread_lock_enabled
+ _thread_lock_enabled = True
+
+def disable_threadlock():
+ global _thread_lock_enabled
+ _thread_lock_enabled = False
+
def execute_handler(name, handler, event, d):
event.data = d
addedd = False
@@ -146,11 +158,17 @@ def print_ui_queue():
logger.handle(event)
def fire_ui_handlers(event, d):
+ global _thread_lock
+ global _thread_lock_enabled
+
if not _uiready:
# No UI handlers registered yet, queue up the messages
ui_queue.append(event)
return
+ if _thread_lock_enabled:
+ _thread_lock.acquire()
+
errors = []
for h in _ui_handlers:
#print "Sending event %s" % event
@@ -169,6 +187,9 @@ def fire_ui_handlers(event, d):
for h in errors:
del _ui_handlers[h]
+ if _thread_lock_enabled:
+ _thread_lock.release()
+
def fire(event, d):
"""Fire off an Event"""
diff --git a/bitbake/lib/toaster/tests/functional/README b/bitbake/lib/toaster/tests/functional/README
new file mode 100644
index 0000000..e69de29
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]