FIXME! Comment out a small code block causing TypeError.
authorBrian Dolbec <dolsen@gentoo.org>
Tue, 22 Jan 2013 08:34:41 +0000 (00:34 -0800)
committerW. Trevor King <wking@tremily.us>
Sun, 15 Dec 2013 04:25:06 +0000 (20:25 -0800)
This was also short circuiting another large code block.  FIXME!!!! This
whole class seems overly complicated with TOO MANY nested try:excepts:

catalyst/lock.py

index 4efb7a4b0b37bc1d181acaf575dca84536eebfc0..d5d40d5e2fe5328f78a043180e9ee2a546bc3776 100644 (file)
@@ -30,11 +30,17 @@ class LockDir:
        locking_method=fcntl.flock
        lock_dirs_in_use=[]
        die_on_failed_lock=True
+
        def __del__(self):
+               #print "Lock.__del__() 1"
                self.clean_my_hardlocks()
+               #print "Lock.__del__() 2"
                self.delete_lock_from_path_list()
+               #print "Lock.__del__() 3"
                if self.islocked():
+                       #print "Lock.__del__() 4"
                        self.fcntl_unlock()
+               #print "Lock.__del__() finnished"
 
        def __init__(self,lockdir):
                self.locked=False
@@ -182,7 +188,9 @@ class LockDir:
                unlinkfile = 1
                if not os.path.exists(self.lockfile):
                        print "lockfile does not exist '%s'" % self.lockfile
+                       #print "fcntl_unlock() , self.myfd:", self.myfd, type(self.myfd)
                        if (self.myfd != None):
+                               #print "fcntl_unlock() trying to close it "
                                try:
                                        os.close(self.myfd)
                                        self.myfd=None
@@ -196,11 +204,13 @@ class LockDir:
                                        unlinkfile = 1
                                        self.locking_method(self.myfd,fcntl.LOCK_UN)
                        except SystemExit, e:
-                               raise
+                               raise e
                        except Exception, e:
-                               os.close(self.myfd)
-                               self.myfd=None
-                               raise IOError, "Failed to unlock file '%s'\n" % self.lockfile
+                               #if self.myfd is not None:
+                                       #print "fcntl_unlock() trying to close", self.myfd
+                                       #os.close(self.myfd)
+                                       #self.myfd=None
+                               #raise IOError, "Failed to unlock file '%s'\n%s" % (self.lockfile, str(e))
                                try:
                                        # This sleep call was added to allow other processes that are
                                        # waiting for a lock to be able to grab it before it is deleted.
@@ -227,7 +237,7 @@ class LockDir:
 #                                              if "DEBUG" in self.settings:
 #                                                      print "Unlinked lockfile..."
                                except SystemExit, e:
-                                       raise
+                                       raise e
                                except Exception, e:
                                        # We really don't care... Someone else has the lock.
                                        # So it is their problem now.
@@ -239,7 +249,7 @@ class LockDir:
                                        # open fd closed automatically on them.
                                        #if type(lockfilename) == types.StringType:
                                        #        os.close(myfd)
-
+               #print "fcntl_unlock() trying a last ditch close", self.myfd
                if (self.myfd != None):
                        os.close(self.myfd)
                        self.myfd=None
@@ -425,6 +435,7 @@ class LockDir:
                                                pass
                return results
 
+
 if __name__ == "__main__":
 
        def lock_work():