summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib/bb')
-rw-r--r--bitbake/lib/bb/event.py10
-rw-r--r--bitbake/lib/bb/utils.py15
2 files changed, 24 insertions, 1 deletions
diff --git a/bitbake/lib/bb/event.py b/bitbake/lib/bb/event.py
index 952c85c0bd..a12adbc937 100644
--- a/bitbake/lib/bb/event.py
+++ b/bitbake/lib/bb/event.py
@@ -194,7 +194,12 @@ def fire_ui_handlers(event, d):
194 ui_queue.append(event) 194 ui_queue.append(event)
195 return 195 return
196 196
197 with bb.utils.lock_timeout(_thread_lock): 197 with bb.utils.lock_timeout_nocheck(_thread_lock) as lock:
198 if not lock:
199 # If we can't get the lock, we may be recursively called, queue and return
200 ui_queue.append(event)
201 return
202
198 errors = [] 203 errors = []
199 for h in _ui_handlers: 204 for h in _ui_handlers:
200 #print "Sending event %s" % event 205 #print "Sending event %s" % event
@@ -213,6 +218,9 @@ def fire_ui_handlers(event, d):
213 for h in errors: 218 for h in errors:
214 del _ui_handlers[h] 219 del _ui_handlers[h]
215 220
221 while ui_queue:
222 fire_ui_handlers(ui_queue.pop(), d)
223
216def fire(event, d): 224def fire(event, d):
217 """Fire off an Event""" 225 """Fire off an Event"""
218 226
diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py
index 3a4b29181e..5486f9599d 100644
--- a/bitbake/lib/bb/utils.py
+++ b/bitbake/lib/bb/utils.py
@@ -1879,6 +1879,9 @@ def path_is_descendant(descendant, ancestor):
1879# If we don't have a timeout of some kind and a process/thread exits badly (for example 1879# If we don't have a timeout of some kind and a process/thread exits badly (for example
1880# OOM killed) and held a lock, we'd just hang in the lock futex forever. It is better 1880# OOM killed) and held a lock, we'd just hang in the lock futex forever. It is better
1881# we exit at some point than hang. 5 minutes with no progress means we're probably deadlocked. 1881# we exit at some point than hang. 5 minutes with no progress means we're probably deadlocked.
1882# This function can still deadlock python since it can't signal the other threads to exit
1883# (signals are handled in the main thread) and even os._exit() will wait on non-daemon threads
1884# to exit.
1882@contextmanager 1885@contextmanager
1883def lock_timeout(lock): 1886def lock_timeout(lock):
1884 try: 1887 try:
@@ -1891,3 +1894,15 @@ def lock_timeout(lock):
1891 finally: 1894 finally:
1892 lock.release() 1895 lock.release()
1893 signal.pthread_sigmask(signal.SIG_SETMASK, s) 1896 signal.pthread_sigmask(signal.SIG_SETMASK, s)
1897
1898# A version of lock_timeout without the check that the lock was locked and a shorter timeout
1899@contextmanager
1900def lock_timeout_nocheck(lock):
1901 try:
1902 s = signal.pthread_sigmask(signal.SIG_BLOCK, signal.valid_signals())
1903 l = lock.acquire(timeout=10)
1904 yield l
1905 finally:
1906 if l:
1907 lock.release()
1908 signal.pthread_sigmask(signal.SIG_SETMASK, s)