diff --git a/libs/checkpoint-postgres/langgraph/checkpoint/postgres/__init__.py b/libs/checkpoint-postgres/langgraph/checkpoint/postgres/__init__.py index b2c187ab5..3c12c4d24 100644 --- a/libs/checkpoint-postgres/langgraph/checkpoint/postgres/__init__.py +++ b/libs/checkpoint-postgres/langgraph/checkpoint/postgres/__init__.py @@ -239,7 +239,8 @@ class PostgresSaver(BasePostgresSaver): with self.conn.cursor(binary=True) as cur: yield cur finally: - self.pipe.sync() + if pipeline: + self.pipe.sync() elif pipeline: # a connection not in pipeline mode can only be used by one # thread/coroutine at a time, so we acquire a lock diff --git a/libs/checkpoint-postgres/langgraph/checkpoint/postgres/aio.py b/libs/checkpoint-postgres/langgraph/checkpoint/postgres/aio.py index e9750d4a1..dd150535c 100644 --- a/libs/checkpoint-postgres/langgraph/checkpoint/postgres/aio.py +++ b/libs/checkpoint-postgres/langgraph/checkpoint/postgres/aio.py @@ -247,7 +247,8 @@ class AsyncPostgresSaver(BasePostgresSaver): async with self.conn.cursor(binary=True) as cur: yield cur finally: - await self.pipe.sync() + if pipeline: + await self.pipe.sync() elif pipeline: # a connection not in pipeline mode can only be used by one # thread/coroutine at a time, so we acquire a lock