[Docstrings] Add reminder to close connection (#864)

In AsyncSqliteSaver, otherwise your program will "hang".

Recommend using async with AsyncSqliteSaver.from_conn_str(...).
This commit is contained in:
William FH
2024-06-27 12:59:26 -07:00
committed by GitHub
parent 5fa2172066
commit bccea30c2a
@@ -46,6 +46,23 @@ class AsyncSqliteSaver(BaseCheckpointSaver, AbstractAsyncContextManager):
for production workloads, due to limitations in SQLite's write performance. For
production workloads, consider using a more robust database like PostgreSQL.
!!! Important
Remember to **close the database connection** after executing your code,
otherwise, you may see the graph "hang" after execution (since the program
will not exit until the connection is closed).
The easiest way to do this is to use the `async with` statement, as shown in the
examples below.
```python
async with AsyncSqliteSaver.from_conn_string("checkpoints.sqlite") as saver:
# Your code here
graph = builder.compile(checkpointer=saver)
config = {"configurable": {"thread_id": "thread-1"}}
async for event in graph.astream_events(..., config, version="v1"):
print(event)
```
Args:
conn (aiosqlite.Connection): The asynchronous SQLite database connection.
serde (Optional[SerializerProtocol]): The serializer to use for serializing and deserializing checkpoints. Defaults to JsonPlusSerializerCompat.