Skip to content

Commit 94c0209

Browse files
committed
fix: add async setup() method to AsyncRedisSaver (#74)
Add async setup() method to AsyncRedisSaver that delegates to asetup() to match the canonical pattern used by PostgreSQL and SQLite checkpointers. This fixes the RuntimeWarning caused by calling the inherited sync setup() method from BaseRedisSaver, which called async create() methods without awaiting them. Maintains backward compatibility by keeping the existing asetup() method while providing the standard async setup() interface that users expect from LangGraph checkpointers. Fixes #74
1 parent cacffce commit 94c0209

File tree

1 file changed

+15
-0
lines changed
  • langgraph/checkpoint/redis

1 file changed

+15
-0
lines changed

langgraph/checkpoint/redis/aio.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,21 @@ async def asetup(self) -> None:
152152
# Detect cluster mode if not explicitly set
153153
await self._detect_cluster_mode()
154154

155+
async def setup(self) -> None: # type: ignore[override]
156+
"""Set up the checkpoint saver asynchronously.
157+
158+
This method creates the necessary indices in Redis and detects cluster mode.
159+
It MUST be called before using the checkpointer.
160+
161+
This async method follows the canonical pattern used by PostgreSQL and SQLite
162+
checkpointers in the LangGraph ecosystem. The type ignore is necessary because
163+
the base class defines a sync setup() method, but async checkpointers require
164+
an async setup() method to properly handle coroutines.
165+
166+
Usage: await checkpointer.setup()
167+
"""
168+
await self.asetup()
169+
155170
async def _detect_cluster_mode(self) -> None:
156171
"""Detect if the Redis client is a cluster client by inspecting its class."""
157172
if self.cluster_mode is not None:

0 commit comments

Comments
 (0)