diff mbox series

[5/6] utils: Add lockfile_to_exclusive

Message ID 20260813124834.1770307-5-richard.purdie@linuxfoundation.org
State New
Headers show
Series [1/6] fetch/__init__: Clean up minor mirror code duplication | expand

Commit Message

Richard Purdie Aug. 13, 2026, 12:48 p.m. UTC
Add a function which turns a shared lock into an exclusive lock. This is
useful for planned changes to the fetcher code.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 lib/bb/utils.py | 7 +++++++
 1 file changed, 7 insertions(+)
diff mbox series

Patch

diff --git a/lib/bb/utils.py b/lib/bb/utils.py
index 92b60b39d2c..b635f68a153 100644
--- a/lib/bb/utils.py
+++ b/lib/bb/utils.py
@@ -587,6 +587,13 @@  def lockfile(name, shared=False, retry=True, block=False):
         if not retry:
             return None
 
+def lockfile_to_exclusive(lf):
+    if not lf:
+        return
+    fileno = lf.fileno()
+    fcntl.flock(fileno, fcntl.LOCK_EX)
+    return
+
 def unlockfile(lf):
     """
     Unlock a file locked using ``bb.utils.lockfile()``.