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