##// END OF EJS Templates
Raise a different exception when the lock is not available...
Benoit Boissinot -
r1753:e6e70450 default
parent child Browse files
Show More
@@ -5,10 +5,14 b''
5 5 # This software may be used and distributed according to the terms
6 6 # of the GNU General Public License, incorporated herein by reference.
7 7
8 import os, time
8 import errno, os, time
9 9 import util
10 10
11 class LockHeld(Exception):
11 class LockException(Exception):
12 pass
13 class LockHeld(LockException):
14 pass
15 class LockUnavailable(LockException):
12 16 pass
13 17
14 18 class lock(object):
@@ -38,8 +42,11 b' class lock(object):'
38 42 try:
39 43 util.makelock(str(pid), self.f)
40 44 self.held = 1
41 except (OSError, IOError):
42 raise LockHeld(util.readlock(self.f))
45 except (OSError, IOError), why:
46 if why.errno == errno.EEXIST:
47 raise LockHeld(util.readlock(self.f))
48 else:
49 raise LockUnavailable(why)
43 50
44 51 def release(self):
45 52 if self.held:
General Comments 0
You need to be logged in to leave comments. Login now