]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Add flags argument to flock()
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Thu, 14 Mar 2024 13:21:14 +0000 (14:21 +0100)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Thu, 14 Mar 2024 13:55:31 +0000 (14:55 +0100)
mkosi/util.py

index 7c107673ab4b32c8c17fb463aab57b3a987c5f5c..0e3c598e877d3558c47f5e8d8046819a02b89403 100644 (file)
@@ -130,12 +130,12 @@ def make_executable(*paths: Path) -> None:
 
 
 @contextlib.contextmanager
-def flock(path: Path) -> Iterator[int]:
+def flock(path: Path, flags: int = fcntl.LOCK_EX) -> Iterator[int]:
     fd = os.open(path, os.O_CLOEXEC|os.O_RDONLY)
     try:
         fcntl.fcntl(fd, fcntl.FD_CLOEXEC)
         logging.debug(f"Acquiring lock on {path}")
-        fcntl.flock(fd, fcntl.LOCK_EX)
+        fcntl.flock(fd, flags)
         logging.debug(f"Acquired lock on {path}")
         yield fd
     finally: