|
|
@@ -6,6 +6,10 @@ class FileLock(object): |
|
|
|
self.f = open(fname, 'w+') |
|
|
|
self.islocked = False |
|
|
|
|
|
|
|
def close(self): |
|
|
|
self.f.close() |
|
|
|
self.islocked = None |
|
|
|
|
|
|
|
def exclusivelock(self): |
|
|
|
fcntl.flock(self.f.fileno(), fcntl.LOCK_EX) |
|
|
|
self.islocked = True |
|
|
@@ -25,5 +29,5 @@ class LockShelve(FileLock, shelve.DbfilenameShelf): |
|
|
|
try: |
|
|
|
shelve.DbfilenameShelf.__init__(self, fname, *args, **kwargs) |
|
|
|
except: |
|
|
|
self.f.close() |
|
|
|
self.close() |
|
|
|
raise |