summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib/bb/utils.py')
-rw-r--r--bitbake/lib/bb/utils.py17
1 files changed, 9 insertions, 8 deletions
diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py
index ba50801ae9..107b001401 100644
--- a/bitbake/lib/bb/utils.py
+++ b/bitbake/lib/bb/utils.py
@@ -401,6 +401,7 @@ def better_eval(source, locals):
401 401
402@contextmanager 402@contextmanager
403def fileslocked(files): 403def fileslocked(files):
404 """Context manager for locking and unlocking file locks."""
404 locks = [] 405 locks = []
405 if files: 406 if files:
406 for lockfile in files: 407 for lockfile in files:
@@ -418,7 +419,7 @@ def lockfile(name):
418 """ 419 """
419 path = os.path.dirname(name) 420 path = os.path.dirname(name)
420 if not os.path.isdir(path): 421 if not os.path.isdir(path):
421 logger.error("Lockfile path '%s' does not exist", path) 422 logger.error("Lockfile destination directory '%s' does not exist", path)
422 sys.exit(1) 423 sys.exit(1)
423 424
424 if not os.access(path, os.W_OK): 425 if not os.access(path, os.W_OK):
@@ -437,16 +438,16 @@ def lockfile(name):
437 # lock is the most likely to win it. 438 # lock is the most likely to win it.
438 439
439 try: 440 try:
440 lf = open(name, "a + ") 441 lf = open(name, 'a+')
441 fcntl.flock(lf.fileno(), fcntl.LOCK_EX) 442 fileno = lf.fileno()
442 statinfo = os.fstat(lf.fileno()) 443 fcntl.flock(fileno, fcntl.LOCK_EX)
444 statinfo = os.fstat(fileno)
443 if os.path.exists(lf.name): 445 if os.path.exists(lf.name):
444 statinfo2 = os.stat(lf.name) 446 statinfo2 = os.stat(lf.name)
445 if statinfo.st_ino == statinfo2.st_ino: 447 if statinfo.st_ino == statinfo2.st_ino:
446 return lf 448 return lf
447 # File no longer exists or changed, retry 449 lf.close()
448 lf.close 450 except Exception:
449 except Exception as e:
450 continue 451 continue
451 452
452def unlockfile(lf): 453def unlockfile(lf):
@@ -455,7 +456,7 @@ def unlockfile(lf):
455 """ 456 """
456 os.unlink(lf.name) 457 os.unlink(lf.name)
457 fcntl.flock(lf.fileno(), fcntl.LOCK_UN) 458 fcntl.flock(lf.fileno(), fcntl.LOCK_UN)
458 lf.close 459 lf.close()
459 460
460def md5_file(filename): 461def md5_file(filename):
461 """ 462 """