Skip to content

Commit 4086a6d

Browse files
committed
fix: async minor cleanups (#562)
- Fix _quantize_vectors docstring: 'documents quantized' not 'processed' - Close internally-created Redis client in async_list_indexes
1 parent 9c4aa07 commit 4086a6d

2 files changed

Lines changed: 12 additions & 6 deletions

File tree

redisvl/migration/async_executor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -871,7 +871,7 @@ async def _async_quantize_vectors(
871871
checkpoint_path: Optional path for checkpoint file (enables resume)
872872
873873
Returns:
874-
Number of documents processed
874+
Number of documents quantized
875875
"""
876876
client = source_index._redis_client
877877
if client is None:

redisvl/migration/async_utils.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,23 @@ async def async_list_indexes(
1414
*, redis_url: Optional[str] = None, redis_client: Optional[AsyncRedisClient] = None
1515
) -> List[str]:
1616
"""List all search indexes in Redis (async version)."""
17+
created_client = False
1718
if redis_client is None:
1819
if not redis_url:
1920
raise ValueError("Must provide either redis_url or redis_client")
2021
redis_client = await RedisConnectionFactory._get_aredis_connection(
2122
redis_url=redis_url
2223
)
23-
index = AsyncSearchIndex.from_dict(
24-
{"index": {"name": "__redisvl_migration_helper__"}, "fields": []},
25-
redis_client=redis_client,
26-
)
27-
return await index.listall()
24+
created_client = True
25+
try:
26+
index = AsyncSearchIndex.from_dict(
27+
{"index": {"name": "__redisvl_migration_helper__"}, "fields": []},
28+
redis_client=redis_client,
29+
)
30+
return await index.listall()
31+
finally:
32+
if created_client:
33+
await redis_client.aclose() # type: ignore[union-attr]
2834

2935

3036
async def async_wait_for_index_ready(

0 commit comments

Comments
 (0)