Commit 6e1ef216 authored by Tiago Peixoto's avatar Tiago Peixoto
Browse files

analyze.py: avoid race condition

parent 402cd86f
......@@ -270,7 +270,8 @@ def analyze_entries(entries, names=[], skip=[], force=[], cache_only=True,
if global_cache:
with acquire_lock_file("./cache/analyze_cache.lock", block=True) as lock:
try:
analyze_cache = pickle.load(open("./cache/analyze_cache.pickle", "rb"))
with open("./cache/analyze_cache.pickle", "rb") as f:
analyze_cache = pickle.load(f)
except FileNotFoundError:
pass
......@@ -318,7 +319,8 @@ def analyze_entries(entries, names=[], skip=[], force=[], cache_only=True,
if global_cache:
with acquire_lock_file("./cache/analyze_cache.lock", block=True) as lock:
pickle.dump(analyze_cache, open("./cache/analyze_cache.pickle", "wb"))
with open("./cache/analyze_cache.pickle", "wb") as f:
pickle.dump(analyze_cache, f)
if __name__ == "__main__":
if len(sys.argv) > 1:
......
Markdown is supported
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