]> code.ossystems Code Review - openembedded-core.git/commitdiff
bitbake utils.py: Fix ocassional locking glitch with a better retrying mechanism
authorRichard Purdie <richard@openedhand.com>
Mon, 6 Oct 2008 08:09:11 +0000 (08:09 +0000)
committerRichard Purdie <richard@openedhand.com>
Mon, 6 Oct 2008 08:09:11 +0000 (08:09 +0000)
git-svn-id: https://svn.o-hand.com/repos/poky/trunk@5415 311d38ba-8fff-0310-9ca6-ca027cbcb966

bitbake-dev/lib/bb/utils.py
bitbake/lib/bb/utils.py

index 89506649fb4c5d051cbb01e23120449a30c14d7c..119f08582d46341ec2bbce21c00d01b69778a34f 100644 (file)
@@ -246,15 +246,18 @@ def lockfile(name):
         # This implementation is unfair since the last person to request the 
         # lock is the most likely to win it.
 
-        lf = open(name, "a+")
-        fcntl.flock(lf.fileno(), fcntl.LOCK_EX)
-        statinfo = os.fstat(lf.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
+        try:
+            lf = open(name, "a+")
+            fcntl.flock(lf.fileno(), fcntl.LOCK_EX)
+            statinfo = os.fstat(lf.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, e:
+            continue
 
 def unlockfile(lf):
     """
index d3701acca7710af99a6daf26390c620e239782af..18fc9f72521fa83f4de155df0b343a9c6cc4dcda 100644 (file)
@@ -246,15 +246,18 @@ def lockfile(name):
         # This implementation is unfair since the last person to request the 
         # lock is the most likely to win it.
 
-        lf = open(name, "a+")
-        fcntl.flock(lf.fileno(), fcntl.LOCK_EX)
-        statinfo = os.fstat(lf.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
+        try:
+            lf = open(name, "a+")
+            fcntl.flock(lf.fileno(), fcntl.LOCK_EX)
+            statinfo = os.fstat(lf.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, e:
+            continue
 
 def unlockfile(lf):
     """