Compare commits

...
3 changed files with 588 additions and 427 deletions
+1 -1
View File
@@ -79,7 +79,7 @@ While LangGraph can be used standalone, it also integrates seamlessly with any L
## Additional resources
- [Guides](https://docs.langchain.com/oss/python/langgraph/guides): Quick, actionable code snippets for topics such as streaming, adding memory & persistence, and design patterns (e.g. branching, subgraphs, etc.).
- [Guides](https://docs.langchain.com/oss/python/langgraph/overview): Quick, actionable code snippets for topics such as streaming, adding memory & persistence, and design patterns (e.g. branching, subgraphs, etc.).
- [Reference](https://reference.langchain.com/python/langgraph/): Detailed reference on core classes, methods, how to use the graph and checkpointing APIs, and higher-level prebuilt components.
- [Examples](https://docs.langchain.com/oss/python/langgraph/agentic-rag): Guided examples on getting started with LangGraph.
- [LangChain Forum](https://forum.langchain.com/): Connect with the community and share all of your technical questions, ideas, and feedback.
@@ -3,6 +3,7 @@ from __future__ import annotations
import asyncio
import json
import random
import threading
from collections.abc import AsyncIterator, Callable, Iterator, Sequence
from contextlib import asynccontextmanager
from typing import Any, TypeVar, cast
@@ -281,8 +282,7 @@ class AsyncSqliteSaver(BaseCheckpointSaver[str]):
async with self.lock:
if self.is_setup:
return
if not self.conn.is_alive():
await self.conn
await _ensure_connected(self.conn)
async with self.conn.executescript(
"""
PRAGMA journal_mode=WAL;
@@ -609,3 +609,23 @@ class AsyncSqliteSaver(BaseCheckpointSaver[str]):
next_v = current_v + 1
next_h = random.random()
return f"{next_v:032}.{next_h:016}"
async def _ensure_connected(conn: aiosqlite.Connection) -> None:
if not _CONN_STARTED_CHECK(conn):
await conn
def _build_conn_started_check() -> Callable[[aiosqlite.Connection], bool]:
is_alive = getattr(aiosqlite.Connection, "is_alive", None)
if callable(is_alive):
return lambda conn: conn.is_alive() # type: ignore[attr-defined]
def _started(conn: aiosqlite.Connection) -> bool:
thread: threading.Thread | None = getattr(conn, "_thread", None)
return False if thread is None else thread.is_alive()
return _started
_CONN_STARTED_CHECK = _build_conn_started_check()
+565 -424
View File
File diff suppressed because it is too large Load Diff