mirror of
https://git.yoctoproject.org/poky
synced 2026-09-19 00:49:33 +02:00
build: use a contextmanager for locks
Also don't bother passing logfile to exec_func_python, at least until we start adding the logfile as a file handler to the bitbake logger. (Bitbake rev: f99ee4680c9f67b7ed13fc06044ba2382f9a782c) Signed-off-by: Chris Larson <chris_larson@mentor.com> Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
This commit is contained in:
committed by
Richard Purdie
parent
b4eff9fcef
commit
e2363f3cdd
@@ -26,6 +26,7 @@ import logging
|
||||
import bb
|
||||
import bb.msg
|
||||
from commands import getstatusoutput
|
||||
from contextlib import contextmanager
|
||||
|
||||
logger = logging.getLogger("BitBake.Util")
|
||||
|
||||
@@ -398,6 +399,18 @@ def simple_exec(code, context):
|
||||
def better_eval(source, locals):
|
||||
return eval(source, _context, locals)
|
||||
|
||||
@contextmanager
|
||||
def fileslocked(files):
|
||||
locks = []
|
||||
if files:
|
||||
for lockfile in files:
|
||||
locks.append(bb.utils.lockfile(lock))
|
||||
|
||||
yield
|
||||
|
||||
for lock in locks:
|
||||
bb.utils.unlockfile(lock)
|
||||
|
||||
def lockfile(name):
|
||||
"""
|
||||
Use the file fn as a lock file, return when the lock has been acquired.
|
||||
|
||||
Reference in New Issue
Block a user