Use "with lock" pattern
While looking at the code to investigate if an why we sometimes don't seem to honor the write lock, I made it use the more modern "with lock:" pattern. Still have not found out how we could ever be using 2 instances of the LocalStatusFolder for the same folder. Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
This commit is contained in:
parent
04ffae2f00
commit
3cb2ddccb8
@ -85,8 +85,7 @@ class LocalStatusFolder(BaseFolder):
|
||||
file.close()
|
||||
|
||||
def save(self):
|
||||
self.savelock.acquire()
|
||||
try:
|
||||
with self.savelock:
|
||||
file = open(self.filename + ".tmp", "wt")
|
||||
file.write(magicline + "\n")
|
||||
for msg in self.messagelist.values():
|
||||
@ -104,9 +103,6 @@ class LocalStatusFolder(BaseFolder):
|
||||
os.fsync(fd)
|
||||
os.close(fd)
|
||||
|
||||
finally:
|
||||
self.savelock.release()
|
||||
|
||||
def getmessagelist(self):
|
||||
return self.messagelist
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user