diff options
Diffstat (limited to 'bitbake')
| -rw-r--r-- | bitbake/lib/bb/utils.py | 17 | 
1 files changed, 9 insertions, 8 deletions
| diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py index ba50801ae..107b00140 100644 --- a/bitbake/lib/bb/utils.py +++ b/bitbake/lib/bb/utils.py @@ -401,6 +401,7 @@ def better_eval(source, locals):  @contextmanager  def fileslocked(files): +    """Context manager for locking and unlocking file locks."""      locks = []      if files:          for lockfile in files: @@ -418,7 +419,7 @@ def lockfile(name):      """      path = os.path.dirname(name)      if not os.path.isdir(path): -        logger.error("Lockfile path '%s' does not exist", path) +        logger.error("Lockfile destination directory '%s' does not exist", path)          sys.exit(1)      if not os.access(path, os.W_OK): @@ -437,16 +438,16 @@ def lockfile(name):          # lock is the most likely to win it.          try: -            lf = open(name, "a + ") -            fcntl.flock(lf.fileno(), fcntl.LOCK_EX) -            statinfo = os.fstat(lf.fileno()) +            lf = open(name, 'a+') +            fileno = lf.fileno() +            fcntl.flock(fileno, fcntl.LOCK_EX) +            statinfo = os.fstat(fileno)              if os.path.exists(lf.name):                  statinfo2 = os.stat(lf.name)                  if statinfo.st_ino == statinfo2.st_ino:                      return lf -            # File no longer exists or changed, retry -            lf.close -        except Exception as e: +            lf.close() +        except Exception:              continue  def unlockfile(lf): @@ -455,7 +456,7 @@ def unlockfile(lf):      """      os.unlink(lf.name)      fcntl.flock(lf.fileno(), fcntl.LOCK_UN) -    lf.close +    lf.close()  def md5_file(filename):      """ | 
