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:
self._state = self._read()
def _read(self):
with FileLock(self._fname):
if not os.path.exists(self._fname):
return {}
with FileLock(self._fname):
with open(self._fname, 'rt') as 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