@@ -170,23 +170,12 @@ async def from_conn_string(
170170 index : Optional [IndexConfig ] = None ,
171171 ) -> AsyncIterator [AsyncRedisStore ]:
172172 """Create store from Redis connection string."""
173- store = cls (redis_url = conn_string , index = index )
174- try :
173+ async with cls (redis_url = conn_string , index = index ) as store :
175174 store ._task = store .loop .create_task (
176175 store ._run_background_tasks (store ._aqueue , weakref .ref (store ))
177176 )
178177 await store .setup ()
179178 yield store
180- finally :
181- if hasattr (store , "_task" ):
182- store ._task .cancel ()
183- try :
184- await store ._task
185- except asyncio .CancelledError :
186- pass
187- if store ._owns_client :
188- await store ._redis .aclose () # type: ignore[attr-defined]
189- await store ._redis .connection_pool .disconnect ()
190179
191180 def create_indexes (self ) -> None :
192181 """Create async indices."""
@@ -212,8 +201,9 @@ async def __aexit__(
212201 except asyncio .CancelledError :
213202 pass
214203
215- # if self._owns_client:
216- await self ._redis .aclose () # type: ignore[attr-defined]
204+ if self ._owns_client :
205+ await self ._redis .aclose () # type: ignore[attr-defined]
206+ await self ._redis .connection_pool .disconnect ()
217207
218208 async def abatch (self , ops : Iterable [Op ]) -> list [Result ]:
219209 """Execute batch of operations asynchronously."""
@@ -301,7 +291,7 @@ async def _batch_get_ops(
301291 res = await self .store_index .search (search_query )
302292
303293 # Use pipeline to get the actual JSON documents
304- pipeline = self ._redis .pipeline ()
294+ pipeline = self ._redis .pipeline (transaction = False )
305295 doc_ids = []
306296 for doc in res .docs :
307297 # The id is already in the correct format (store:prefix:key)
@@ -481,7 +471,7 @@ async def _batch_search_ops(
481471 )
482472
483473 # Get matching store docs in pipeline
484- pipeline = self ._redis .pipeline ()
474+ pipeline = self ._redis .pipeline (transaction = False )
485475 result_map = {} # Map store key to vector result with distances
486476
487477 for doc in vector_results :
0 commit comments