mirror of
https://github.com/oobabooga/text-generation-webui.git
synced 2026-04-04 22:27:29 +00:00
UI: Minor defensive changes to autosave
This commit is contained in:
parent
bb00d96dc3
commit
980a9d1657
2 changed files with 13 additions and 6 deletions
|
|
@ -6,6 +6,7 @@ import json
|
|||
import pprint
|
||||
import re
|
||||
import shutil
|
||||
import threading
|
||||
import time
|
||||
from datetime import datetime
|
||||
from functools import partial
|
||||
|
|
@ -40,6 +41,8 @@ from modules.utils import (
|
|||
)
|
||||
from modules.web_search import add_web_search_attachments
|
||||
|
||||
_history_file_lock = threading.Lock()
|
||||
|
||||
|
||||
def strftime_now(format):
|
||||
return datetime.now().strftime(format)
|
||||
|
|
@ -1200,8 +1203,9 @@ def save_history(history, unique_id, character, mode):
|
|||
if not p.parent.is_dir():
|
||||
p.parent.mkdir(parents=True)
|
||||
|
||||
with open(p, 'w', encoding='utf-8') as f:
|
||||
f.write(json.dumps(history, indent=4, ensure_ascii=False))
|
||||
with _history_file_lock:
|
||||
with open(p, 'w', encoding='utf-8') as f:
|
||||
f.write(json.dumps(history, indent=4, ensure_ascii=False))
|
||||
|
||||
|
||||
def rename_history(old_id, new_id, character, mode):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue