Skip to content

Commit 8386ee3

Browse files
authored
fix: [2.4] RuntimeWarning: coroutine 'Channel.close' was never awaited when closing async client (#2498)
Signed-off-by: Ruichen Bao <ruichen.bao@zju.edu.cn>
1 parent cca72b5 commit 8386ee3

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

pymilvus/client/async_grpc_handler.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,9 @@ def __enter__(self):
108108
def __exit__(self: object, exc_type: object, exc_val: object, exc_tb: object):
109109
pass
110110

111-
def close(self):
111+
async def close(self):
112112
self.deregister_state_change_callbacks()
113-
self._async_channel.close()
113+
await self._async_channel.close()
114114

115115
def _setup_authorization_interceptor(self, user: str, password: str, token: str):
116116
keys = []

pymilvus/milvus_client/async_milvus_client.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -516,8 +516,8 @@ def create_schema(cls, **kwargs):
516516
kwargs["check_fields"] = False # do not check fields for now
517517
return CollectionSchema([], **kwargs)
518518

519-
def close(self):
520-
connections.disconnect(self._using)
519+
async def close(self):
520+
await connections.async_disconnect(self._using)
521521

522522
def _get_connection(self):
523523
return connections._fetch_handler(self._using)

pymilvus/orm/connections.py

+7
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,13 @@ def disconnect(self, alias: str):
285285
if alias in self._connected_alias:
286286
self._connected_alias.pop(alias).close()
287287

288+
async def async_disconnect(self, alias: str):
289+
if not isinstance(alias, str):
290+
raise ConnectionConfigException(message=ExceptionsMessage.AliasType % type(alias))
291+
292+
if alias in self._connected_alias:
293+
await self._connected_alias.pop(alias).close()
294+
288295
def remove_connection(self, alias: str):
289296
"""Removes connection from the registry.
290297

0 commit comments

Comments
 (0)