utils: Pass lock argument in fileslocked
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.
Signed-off-by Joshua Watt <[email protected]>
--- bitbake/lib/bb/utils.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
bitbake/lib/bb/utils.py +4 -2
@@ -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