diff options
Diffstat (limited to 'bitbake/lib/bb/utils.py')
-rw-r--r-- | bitbake/lib/bb/utils.py | 15 |
1 files changed, 15 insertions, 0 deletions
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 |
1883 | def lock_timeout(lock): | 1886 | def 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 | ||
1900 | def 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) | ||