diff mbox series

[scarthgap,2.8,2/4] utils: Tweak lock_timeout logic

Message ID 36e8e310faa4e5d572a13c0cf9ec82680cf8f5b9.1741206585.git.steve@sakoman.com
State New
Headers show
Series [scarthgap,2.8,1/4] utils: Print information about lock issue before exiting | expand

Commit Message

Steve Sakoman March 5, 2025, 10:09 p.m. UTC
From: Richard Purdie <richard.purdie@linuxfoundation.org>

We should really try and take the lock in the try/finally block so that
in some rare cases such as badly timed interrupt/signal, we always release
the lock.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit a9eb8bf7174b6962b5ba07192fe95b8c7112d9d2)
Signed-off-by: Steve Sakoman <steve@sakoman.com>
---
 lib/bb/utils.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/lib/bb/utils.py b/lib/bb/utils.py
index 0dfe47dc5..83e832c33 100644
--- a/lib/bb/utils.py
+++ b/lib/bb/utils.py
@@ -1859,8 +1859,8 @@  def path_is_descendant(descendant, ancestor):
 # we exit at some point than hang. 5 minutes with no progress means we're probably deadlocked.
 @contextmanager
 def lock_timeout(lock):
-    held = lock.acquire(timeout=5*60)
     try:
+        held = lock.acquire(timeout=5*60)
         if not held:
             bb.server.process.serverlog("Couldn't get the lock for 5 mins, timed out, exiting.\n%s" % traceback.format_stack())
             os._exit(1)