aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoshua Watt <JPEWhacker@gmail.com>2022-08-30 10:59:09 -0500
committerRichard Purdie <richard.purdie@linuxfoundation.org>2022-09-02 11:45:17 +0100
commit048d682b031644fb9f0d41a489bacb873aa27bd7 (patch)
treebc66c12345ba1dadd67d5d1a0d3b1a9230bfa31d
parent3b719e8e115b7fde869f62ddc180e045c1b51cdf (diff)
downloadbitbake-contrib-048d682b031644fb9f0d41a489bacb873aa27bd7.tar.gz
utils: Pass lock argument in fileslocked
Pass additional arguments in the fileslocked() context manager to the underlying lockfile() function. This allows the context manager to be used for any types of locks (non-blocking, shared, etc.) that the lockfile() function supports. Signed-off-by: Joshua Watt <JPEWhacker@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--lib/bb/utils.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/bb/utils.py b/lib/bb/utils.py
index fab16ffc5..6592eb00d 100644
--- a/lib/bb/utils.py
+++ b/lib/bb/utils.py
@@ -421,12 +421,14 @@ def better_eval(source, locals, extraglobals = None):
return eval(source, ctx, locals)
@contextmanager
-def fileslocked(files):
+def fileslocked(files, *args, **kwargs):
"""Context manager for locking and unlocking file locks."""
locks = []
if files:
for lockfile in files:
- locks.append(bb.utils.lockfile(lockfile))
+ l = bb.utils.lockfile(lockfile, *args, **kwargs)
+ if l is not None:
+ locks.append(l)
try:
yield