[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

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



commit 850271a127956213d432e93e9e0fdab0689a1cf6
Author: juga0 <juga@xxxxxxxxxx>
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)
 



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits