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()
|
file.close()
|
||||||
|
|
||||||
def save(self):
|
def save(self):
|
||||||
self.savelock.acquire()
|
with self.savelock:
|
||||||
try:
|
|
||||||
file = open(self.filename + ".tmp", "wt")
|
file = open(self.filename + ".tmp", "wt")
|
||||||
file.write(magicline + "\n")
|
file.write(magicline + "\n")
|
||||||
for msg in self.messagelist.values():
|
for msg in self.messagelist.values():
|
||||||
@ -104,9 +103,6 @@ class LocalStatusFolder(BaseFolder):
|
|||||||
os.fsync(fd)
|
os.fsync(fd)
|
||||||
os.close(fd)
|
os.close(fd)
|
||||||
|
|
||||||
finally:
|
|
||||||
self.savelock.release()
|
|
||||||
|
|
||||||
def getmessagelist(self):
|
def getmessagelist(self):
|
||||||
return self.messagelist
|
return self.messagelist
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user