summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/utils.py
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2011-05-27 16:13:27 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2011-05-27 17:55:51 +0100
commit5573852a826d2806c397a27896c4884bf094387d (patch)
treef94fcab3e367db4f6d030885bc479833925ebfd9 /bitbake/lib/bb/utils.py
parent00c71132d5a326546bbb7fdf173995c76a9e9803 (diff)
downloadpoky-5573852a826d2806c397a27896c4884bf094387d.tar.gz
bitbake/utils.py: Add option to lockfiles to return immediately rather than wait
There are usecases where we don't want to block waiting for a lockfile so enhance the lockfile handling functions to support this. (Bitbake rev: 97e8adf03e5fab1fd40c3d53c48f7b333bc2e145) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/utils.py')
-rw-r--r--bitbake/lib/bb/utils.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py
index ccafda19e3..82e5dc4277 100644
--- a/bitbake/lib/bb/utils.py
+++ b/bitbake/lib/bb/utils.py
@@ -402,7 +402,7 @@ def fileslocked(files):
402 for lock in locks: 402 for lock in locks:
403 bb.utils.unlockfile(lock) 403 bb.utils.unlockfile(lock)
404 404
405def lockfile(name, shared=False): 405def lockfile(name, shared=False, retry=True):
406 """ 406 """
407 Use the file fn as a lock file, return when the lock has been acquired. 407 Use the file fn as a lock file, return when the lock has been acquired.
408 Returns a variable to pass to unlockfile(). 408 Returns a variable to pass to unlockfile().
@@ -418,6 +418,8 @@ def lockfile(name, shared=False):
418 op = fcntl.LOCK_EX 418 op = fcntl.LOCK_EX
419 if shared: 419 if shared:
420 op = fcntl.LOCK_SH 420 op = fcntl.LOCK_SH
421 if not retry:
422 op = op | fcntl.LOCK_NB
421 423
422 while True: 424 while True:
423 # If we leave the lockfiles lying around there is no problem 425 # If we leave the lockfiles lying around there is no problem
@@ -442,6 +444,8 @@ def lockfile(name, shared=False):
442 lf.close() 444 lf.close()
443 except Exception: 445 except Exception:
444 continue 446 continue
447 if not retry:
448 return None
445 449
446def unlockfile(lf): 450def unlockfile(lf):
447 """ 451 """