提交 bb7dd7b6 编写于 作者: A AUTOMATIC1111

use an atomic operation to replace the cache with the new version

上级 9c82b34b
......@@ -30,9 +30,12 @@ def dump_cache():
time.sleep(1)
with cache_lock:
with open(cache_filename, "w", encoding="utf8") as file:
cache_filename_tmp = cache_filename + "-"
with open(cache_filename_tmp, "w", encoding="utf8") as file:
json.dump(cache_data, file, indent=4)
os.replace(cache_filename_tmp, cache_filename)
dump_cache_after = None
dump_cache_thread = None
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册