Show More
@@ -12,10 +12,11 b' class LockHeld(Exception):' | |||
|
12 | 12 | pass |
|
13 | 13 | |
|
14 | 14 | class lock: |
|
15 | def __init__(self, file, wait=1): | |
|
15 | def __init__(self, file, wait=1, releasefn=None): | |
|
16 | 16 | self.f = file |
|
17 | 17 | self.held = 0 |
|
18 | 18 | self.wait = wait |
|
19 | self.releasefn = releasefn | |
|
19 | 20 | self.lock() |
|
20 | 21 | |
|
21 | 22 | def __del__(self): |
@@ -43,6 +44,8 b' class lock:' | |||
|
43 | 44 | def release(self): |
|
44 | 45 | if self.held: |
|
45 | 46 | self.held = 0 |
|
47 | if self.releasefn: | |
|
48 | self.releasefn() | |
|
46 | 49 | try: |
|
47 | 50 | os.unlink(self.f) |
|
48 | 51 | except: pass |
General Comments 0
You need to be logged in to leave comments.
Login now