There are usecases where we don't want to block waiting for a lockfile
so enhance the lockfile handling functions to support this.
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
for lock in locks:
bb.utils.unlockfile(lock)
-def lockfile(name, shared=False):
+def lockfile(name, shared=False, retry=True):
"""
Use the file fn as a lock file, return when the lock has been acquired.
Returns a variable to pass to unlockfile().
op = fcntl.LOCK_EX
if shared:
op = fcntl.LOCK_SH
+ if not retry:
+ op = op | fcntl.LOCK_NB
while True:
# If we leave the lockfiles lying around there is no problem
lf.close()
except Exception:
continue
+ if not retry:
+ return None
def unlockfile(lf):
"""