sync update from LAN repo (source dhk-1 @ 3b1ec5b4)

This commit is contained in:
gozeros committed 2026-11-05 10:56:34 +08:00
1 parent da6521b6cb
commit 264e2200d6
995 files changed
+148105 -13399

No files matched your search

@@ -20,13 +20,14 @@ from __future__ import annotations
import asyncio
import contextlib
import logging
from collections.abc import AsyncIterator
import os
from collections.abc import AsyncIterator
from pathlib import Path
from langgraph.types import Checkpointer
from deerflow.config.app_config import AppConfig, get_app_config
from deerflow.runtime.checkpointer.chat_archive import archive_root
from deerflow.runtime.checkpointer.provider import (
POSTGRES_CONN_REQUIRED,
POSTGRES_INSTALL,
@@ -135,7 +136,11 @@ async def _sqlite_checkpointer_from_conn_str(raw: str) -> AsyncIterator[Checkpoi
conn_str = resolve_sqlite_conn_str(raw)
await asyncio.to_thread(ensure_sqlite_parent_dir, conn_str)
async with AsyncSqliteSaver.from_conn_string(conn_str) as saver:
await saver.setup()
from deerflow.runtime.store._sqlite_setup import sqlite_setup_lock
async with sqlite_setup_lock(conn_str):
await saver.conn.execute("PRAGMA busy_timeout=30000")
await saver.setup()
yield saver
@@ -174,15 +179,20 @@ async def _async_checkpointer(config) -> AsyncIterator[Checkpointer]:
if not config.connection_string:
raise ValueError(POSTGRES_CONN_REQUIRED)
from deerflow.runtime.checkpointer.checkpoint_migration import DualReadCheckpointer
async with _postgres_saver_from_pool(config.connection_string) as saver:
if not _dual_read_enabled(config):
yield saver
proxy = DualReadCheckpointer(saver, [], archive_dir=archive_root())
try:
yield proxy
finally:
await proxy.aclose_sources()
return
from langgraph.checkpoint.sqlite.aio import AsyncSqliteSaver
from deerflow.runtime.checkpointer.checkpoint_migration import (
DualReadCheckpointer,
SQLiteCheckpointSource,
)
@@ -205,12 +215,17 @@ async def _async_checkpointer(config) -> AsyncIterator[Checkpointer]:
if not sources:
logger.info("Checkpoint dual-read enabled but no SQLite sources were opened; using Postgres only")
yield saver
proxy = DualReadCheckpointer(saver, [], archive_dir=archive_root())
try:
yield proxy
finally:
await proxy.aclose_sources()
return
proxy = DualReadCheckpointer(
saver,
sources,
archive_dir=archive_root(),
)
try:
yield proxy
@@ -257,8 +272,14 @@ async def _async_checkpointer_from_database(db_config) -> AsyncIterator[Checkpoi
if not db_config.postgres_url:
raise ValueError("database.postgres_url is required for the postgres backend")
from deerflow.runtime.checkpointer.checkpoint_migration import DualReadCheckpointer
async with _postgres_saver_from_pool(db_config.postgres_url) as saver:
yield saver
proxy = DualReadCheckpointer(saver, [], archive_dir=archive_root())
try:
yield proxy
finally:
await proxy.aclose_sources()
return
raise ValueError(f"Unknown database backend: {db_config.backend!r}")