[sbws/master] Check if file exists before locking it

18 Sep
2018
18 Sep
'18
9:26 a.m.
commit 850271a127956213d432e93e9e0fdab0689a1cf6 Author: juga0 <juga@riseup.net> Date: Wed Aug 29 18:50:48 2018 +0000 Check if file exists before locking it --- sbws/util/state.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sbws/util/state.py b/sbws/util/state.py index a13ee13..ce3dbb9 100644 --- a/sbws/util/state.py +++ b/sbws/util/state.py @@ -48,9 +48,9 @@ class State: self._state = self._read() def _read(self): + if not os.path.exists(self._fname): + return {} with FileLock(self._fname): - if not os.path.exists(self._fname): - return {} with open(self._fname, 'rt') as fd: return json.load(fd)
2454
Age (days ago)
2454
Last active (days ago)
0 comments
1 participants
participants (1)
-
juga@torproject.org