Gentoo Archives: gentoo-catalyst

From: Brian Dolbec <dolsen@g.o>
To: gentoo-catalyst@l.g.o
Subject: [gentoo-catalyst] [PATCH 1/6] FIXME! Comment out a small code block causing TypeError.
Date: Thu, 11 Sep 2014 04:01:17
Message-Id: 1410408068-3441-2-git-send-email-dolsen@gentoo.org
In Reply to: [gentoo-catalyst] [PATCH 0/6] Various changes towards 3.0 branch by Brian Dolbec
1 This was also short circuiting another large code block. FIXME!!!! This
2 whole class seems overly complicated with TOO MANY nested try:excepts:
3 ---
4 catalyst/lock.py | 23 +++++++++++++++++------
5 1 file changed, 17 insertions(+), 6 deletions(-)
6
7 diff --git a/catalyst/lock.py b/catalyst/lock.py
8 index 78968cb..c90f5b8 100644
9 --- a/catalyst/lock.py
10 +++ b/catalyst/lock.py
11 @@ -27,11 +27,17 @@ class LockDir:
12 locking_method=fcntl.flock
13 lock_dirs_in_use=[]
14 die_on_failed_lock=True
15 +
16 def __del__(self):
17 + #print "Lock.__del__() 1"
18 self.clean_my_hardlocks()
19 + #print "Lock.__del__() 2"
20 self.delete_lock_from_path_list()
21 + #print "Lock.__del__() 3"
22 if self.islocked():
23 + #print "Lock.__del__() 4"
24 self.fcntl_unlock()
25 + #print "Lock.__del__() finnished"
26
27 def __init__(self,lockdir):
28 self.locked=False
29 @@ -179,7 +185,9 @@ class LockDir:
30 unlinkfile = 1
31 if not os.path.exists(self.lockfile):
32 print "lockfile does not exist '%s'" % self.lockfile
33 + #print "fcntl_unlock() , self.myfd:", self.myfd, type(self.myfd)
34 if (self.myfd != None):
35 + #print "fcntl_unlock() trying to close it "
36 try:
37 os.close(self.myfd)
38 self.myfd=None
39 @@ -193,11 +201,13 @@ class LockDir:
40 unlinkfile = 1
41 self.locking_method(self.myfd,fcntl.LOCK_UN)
42 except SystemExit, e:
43 - raise
44 + raise e
45 except Exception, e:
46 - os.close(self.myfd)
47 - self.myfd=None
48 - raise IOError, "Failed to unlock file '%s'\n" % self.lockfile
49 + #if self.myfd is not None:
50 + #print "fcntl_unlock() trying to close", self.myfd
51 + #os.close(self.myfd)
52 + #self.myfd=None
53 + #raise IOError, "Failed to unlock file '%s'\n%s" % (self.lockfile, str(e))
54 try:
55 # This sleep call was added to allow other processes that are
56 # waiting for a lock to be able to grab it before it is deleted.
57 @@ -224,7 +234,7 @@ class LockDir:
58 # if "DEBUG" in self.settings:
59 # print "Unlinked lockfile..."
60 except SystemExit, e:
61 - raise
62 + raise e
63 except Exception, e:
64 # We really don't care... Someone else has the lock.
65 # So it is their problem now.
66 @@ -236,7 +246,7 @@ class LockDir:
67 # open fd closed automatically on them.
68 #if type(lockfilename) == types.StringType:
69 # os.close(myfd)
70 -
71 + #print "fcntl_unlock() trying a last ditch close", self.myfd
72 if (self.myfd != None):
73 os.close(self.myfd)
74 self.myfd=None
75 @@ -421,6 +431,7 @@ class LockDir:
76 pass
77 return results
78
79 +
80 if __name__ == "__main__":
81
82 def lock_work():
83 --
84 2.1.0