mirror of
https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
synced 2025-04-17 02:19:01 +08:00
use an atomic operation to replace the cache with the new version
This commit is contained in:
parent
9c82b34be7
commit
bb7dd7b646
@ -30,9 +30,12 @@ def dump_cache():
|
|||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
||||||
with cache_lock:
|
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)
|
json.dump(cache_data, file, indent=4)
|
||||||
|
|
||||||
|
os.replace(cache_filename_tmp, cache_filename)
|
||||||
|
|
||||||
dump_cache_after = None
|
dump_cache_after = None
|
||||||
dump_cache_thread = None
|
dump_cache_thread = None
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user