diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2011-05-27 16:13:27 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2011-05-27 17:24:12 +0100 |
commit | 97e8adf03e5fab1fd40c3d53c48f7b333bc2e145 (patch) | |
tree | 4314c6a91029793f4f644b970a588dfd14d49255 /lib/bb/utils.py | |
parent | c12dd868368bdc3a4f800e075a30c67edca28d47 (diff) | |
download | bitbake-contrib-97e8adf03e5fab1fd40c3d53c48f7b333bc2e145.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.
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'lib/bb/utils.py')
-rw-r--r-- | lib/bb/utils.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/bb/utils.py b/lib/bb/utils.py index ccafda19e..82e5dc427 100644 --- a/lib/bb/utils.py +++ b/lib/bb/utils.py @@ -402,7 +402,7 @@ def fileslocked(files): 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(). @@ -418,6 +418,8 @@ def lockfile(name, shared=False): 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 @@ -442,6 +444,8 @@ def lockfile(name, shared=False): lf.close() except Exception: continue + if not retry: + return None def unlockfile(lf): """ |