Skip to contentSkip to conversation

utils: Pass lock argument in fileslocked

PATCH New Joshua Watt 1 participant 1 message Aug 30, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 bitbake/lib/bb/utils.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
bitbake/lib/bb/utils.py +4 -2
index b8b90df8d3..92d44c5260 100644
@@ -431,12 +431,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
Signature · 1 line
2.33.0