summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/utils.py
diff options
context:
space:
mode:
authorChris Larson <chris_larson@mentor.com>2010-12-09 20:29:31 -0500
committerRichard Purdie <rpurdie@linux.intel.com>2011-01-04 14:46:48 +0000
commite2363f3cdddb597c0321b6c396306be966ac58f9 (patch)
treecef6f4fd59a91c558a528b841c3159f264f68234 /bitbake/lib/bb/utils.py
parentb4eff9fcefe2fefab1caaf22e497317e9338063e (diff)
downloadpoky-e2363f3cdddb597c0321b6c396306be966ac58f9.tar.gz
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>
Diffstat (limited to 'bitbake/lib/bb/utils.py')
-rw-r--r--bitbake/lib/bb/utils.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py
index d9f543bc60..ba50801ae9 100644
--- a/bitbake/lib/bb/utils.py
+++ b/bitbake/lib/bb/utils.py
@@ -26,6 +26,7 @@ import logging
26import bb 26import bb
27import bb.msg 27import bb.msg
28from commands import getstatusoutput 28from commands import getstatusoutput
29from contextlib import contextmanager
29 30
30logger = logging.getLogger("BitBake.Util") 31logger = logging.getLogger("BitBake.Util")
31 32
@@ -398,6 +399,18 @@ def simple_exec(code, context):
398def better_eval(source, locals): 399def better_eval(source, locals):
399 return eval(source, _context, locals) 400 return eval(source, _context, locals)
400 401
402@contextmanager
403def fileslocked(files):
404 locks = []
405 if files:
406 for lockfile in files:
407 locks.append(bb.utils.lockfile(lock))
408
409 yield
410
411 for lock in locks:
412 bb.utils.unlockfile(lock)
413
401def lockfile(name): 414def lockfile(name):
402 """ 415 """
403 Use the file fn as a lock file, return when the lock has been acquired. 416 Use the file fn as a lock file, return when the lock has been acquired.