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 da026fe5bf..67e22f4389 100644 --- a/bitbake/lib/bb/utils.py +++ b/bitbake/lib/bb/utils.py | |||
@@ -1857,6 +1857,9 @@ def path_is_descendant(descendant, ancestor): | |||
1857 | # If we don't have a timeout of some kind and a process/thread exits badly (for example | 1857 | # If we don't have a timeout of some kind and a process/thread exits badly (for example |
1858 | # OOM killed) and held a lock, we'd just hang in the lock futex forever. It is better | 1858 | # OOM killed) and held a lock, we'd just hang in the lock futex forever. It is better |
1859 | # we exit at some point than hang. 5 minutes with no progress means we're probably deadlocked. | 1859 | # we exit at some point than hang. 5 minutes with no progress means we're probably deadlocked. |
1860 | # This function can still deadlock python since it can't signal the other threads to exit | ||
1861 | # (signals are handled in the main thread) and even os._exit() will wait on non-daemon threads | ||
1862 | # to exit. | ||
1860 | @contextmanager | 1863 | @contextmanager |
1861 | def lock_timeout(lock): | 1864 | def lock_timeout(lock): |
1862 | try: | 1865 | try: |
@@ -1869,3 +1872,15 @@ def lock_timeout(lock): | |||
1869 | finally: | 1872 | finally: |
1870 | lock.release() | 1873 | lock.release() |
1871 | signal.pthread_sigmask(signal.SIG_SETMASK, s) | 1874 | signal.pthread_sigmask(signal.SIG_SETMASK, s) |
1875 | |||
1876 | # A version of lock_timeout without the check that the lock was locked and a shorter timeout | ||
1877 | @contextmanager | ||
1878 | def lock_timeout_nocheck(lock): | ||
1879 | try: | ||
1880 | s = signal.pthread_sigmask(signal.SIG_BLOCK, signal.valid_signals()) | ||
1881 | l = lock.acquire(timeout=10) | ||
1882 | yield l | ||
1883 | finally: | ||
1884 | if l: | ||
1885 | lock.release() | ||
1886 | signal.pthread_sigmask(signal.SIG_SETMASK, s) | ||