From: Daan De Meyer Date: Thu, 14 Mar 2024 13:21:14 +0000 (+0100) Subject: Add flags argument to flock() X-Git-Tag: v23~94^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=44a7e8fdb5876da37e66c6248c6192fdbe89d4e6;p=thirdparty%2Fmkosi.git Add flags argument to flock() --- diff --git a/mkosi/util.py b/mkosi/util.py index 7c107673a..0e3c598e8 100644 --- a/mkosi/util.py +++ b/mkosi/util.py @@ -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: