diff --git a/libs/checkpoint-duckdb/langgraph/checkpoint/duckdb/aio.py b/libs/checkpoint-duckdb/langgraph/checkpoint/duckdb/aio.py index 54c1924cc..bf48b0e0a 100644 --- a/libs/checkpoint-duckdb/langgraph/checkpoint/duckdb/aio.py +++ b/libs/checkpoint-duckdb/langgraph/checkpoint/duckdb/aio.py @@ -346,6 +346,18 @@ def list( Yields: Iterator[CheckpointTuple]: An iterator of matching checkpoint tuples. """ + try: + # check if we are in the main thread, only bg threads can block + # we don't check in other methods to avoid the overhead + if asyncio.get_running_loop() is self.loop: + raise asyncio.InvalidStateError( + "Synchronous calls to AsyncDuckDBSaver are only allowed from a " + "different thread. From the main thread, use the async interface. " + "For example, use `checkpointer.alist(...)` or `await " + "graph.ainvoke(...)`." + ) + except RuntimeError: + pass aiter_ = self.alist(config, filter=filter, before=before, limit=limit) while True: try: diff --git a/libs/checkpoint-postgres/langgraph/checkpoint/postgres/aio.py b/libs/checkpoint-postgres/langgraph/checkpoint/postgres/aio.py index e5db87c70..0dbfa9108 100644 --- a/libs/checkpoint-postgres/langgraph/checkpoint/postgres/aio.py +++ b/libs/checkpoint-postgres/langgraph/checkpoint/postgres/aio.py @@ -385,7 +385,7 @@ def list( # we don't check in other methods to avoid the overhead if asyncio.get_running_loop() is self.loop: raise asyncio.InvalidStateError( - "Synchronous calls to AsyncSqliteSaver are only allowed from a " + "Synchronous calls to AsyncPostgresSaver are only allowed from a " "different thread. From the main thread, use the async interface. " "For example, use `checkpointer.alist(...)` or `await " "graph.ainvoke(...)`."