Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions libs/checkpoint/langgraph/checkpoint/memory/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ def __init__(
self.stack.enter_context(self.blobs) # type: ignore[arg-type]

def __enter__(self) -> InMemorySaver:
return self.stack.__enter__()
self.stack.__enter__()
return self

def __exit__(
self,
Expand All @@ -108,7 +109,8 @@ def __exit__(
return self.stack.__exit__(exc_type, exc_value, traceback)

async def __aenter__(self) -> InMemorySaver:
return self.stack.__enter__()
self.stack.__enter__()
return self

async def __aexit__(
self,
Expand Down
11 changes: 9 additions & 2 deletions libs/checkpoint/tests/test_memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,14 @@ async def test_asearch(self) -> None:
assert len(search_results_4) == 0


def test_memory_saver() -> None:
async def test_memory_saver() -> None:
from langgraph.checkpoint.memory import InMemorySaver

assert isinstance(InMemorySaver(), InMemorySaver)
memory_saver = InMemorySaver()
assert isinstance(memory_saver, InMemorySaver)

async with memory_saver as async_memory_saver:
assert async_memory_saver is memory_saver

with memory_saver as sync_memory_saver:
assert sync_memory_saver is memory_saver