class Lock: set lockfile = None before trying to open a file.
In case the open causes a delay and we got a KeyboardInterrupt, this prevents a weird error from the destructor about an uninitialized variable.
This commit is contained in:
parent
f4f9ed97ec
commit
d143cca7da
1 changed files with 3 additions and 1 deletions
2
state.py
2
state.py
|
|
@ -335,6 +335,7 @@ class Lock:
|
|||
def __init__(self, fid):
|
||||
self.owned = False
|
||||
self.fid = fid
|
||||
self.lockfile = None
|
||||
self.lockfile = os.open(os.path.join(vars.BASE, '.redo/lock.%d' % fid),
|
||||
os.O_RDWR | os.O_CREAT, 0666)
|
||||
close_on_exec(self.lockfile, True)
|
||||
|
|
@ -345,6 +346,7 @@ class Lock:
|
|||
_locks[self.fid] = 0
|
||||
if self.owned:
|
||||
self.unlock()
|
||||
if self.lockfile is not None:
|
||||
os.close(self.lockfile)
|
||||
|
||||
def trylock(self):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue