update
This commit is contained in:
@@ -11,6 +11,7 @@ from threading import Lock
|
||||
from app.core.config import get_settings
|
||||
|
||||
_registry_lock = Lock()
|
||||
_backend_init_lock = Lock()
|
||||
_locks: dict[str, tuple[Lock, int]] = {}
|
||||
|
||||
|
||||
@@ -37,7 +38,7 @@ def thread_lock(key):
|
||||
|
||||
|
||||
@lru_cache(maxsize=4)
|
||||
def _backend(url):
|
||||
def _cached_backend(url):
|
||||
if url.startswith("sqlite:///"):
|
||||
from langgraph.checkpoint.sqlite import SqliteSaver
|
||||
file = url.removeprefix("sqlite:///")
|
||||
@@ -59,6 +60,14 @@ def _backend(url):
|
||||
raise ValueError("Unsupported assistant checkpoint database")
|
||||
|
||||
|
||||
def _backend(url):
|
||||
# lru_cache permits concurrent cache misses to run the initializer twice.
|
||||
# SQLite setup must be single-flight, or simultaneous first requests can
|
||||
# race schema/journal initialization before conversation locks are acquired.
|
||||
with _backend_init_lock:
|
||||
return _cached_backend(url)
|
||||
|
||||
|
||||
@contextmanager
|
||||
def planning_session(payload):
|
||||
from app.modules.work_assistant.orchestration import build_planning_graph
|
||||
|
||||
Reference in New Issue
Block a user