Commit 850271a1 authored by juga's avatar juga
Browse files

Check if file exists before locking it

parent cf9a55a3
...@@ -48,9 +48,9 @@ class State: ...@@ -48,9 +48,9 @@ class State:
self._state = self._read() self._state = self._read()
def _read(self): def _read(self):
if not os.path.exists(self._fname):
return {}
with FileLock(self._fname): with FileLock(self._fname):
if not os.path.exists(self._fname):
return {}
with open(self._fname, 'rt') as fd: with open(self._fname, 'rt') as fd:
return json.load(fd) return json.load(fd)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment