Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: [2.5] RuntimeWarning: coroutine 'Channel.close' was never awaited when closing async client #2499

Merged
merged 1 commit into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pymilvus/client/async_grpc_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ def __enter__(self):
def __exit__(self: object, exc_type: object, exc_val: object, exc_tb: object):
pass

def close(self):
async def close(self):
self.deregister_state_change_callbacks()
self._async_channel.close()
await self._async_channel.close()

def _setup_authorization_interceptor(self, user: str, password: str, token: str):
keys = []
Expand Down
4 changes: 2 additions & 2 deletions pymilvus/milvus_client/async_milvus_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -516,8 +516,8 @@ def create_schema(cls, **kwargs):
kwargs["check_fields"] = False # do not check fields for now
return CollectionSchema([], **kwargs)

def close(self):
connections.disconnect(self._using)
async def close(self):
await connections.async_disconnect(self._using)

def _get_connection(self):
return connections._fetch_handler(self._using)
Expand Down
7 changes: 7 additions & 0 deletions pymilvus/orm/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,13 @@ def disconnect(self, alias: str):
if alias in self._connected_alias:
self._connected_alias.pop(alias).close()

async def async_disconnect(self, alias: str):
if not isinstance(alias, str):
raise ConnectionConfigException(message=ExceptionsMessage.AliasType % type(alias))

if alias in self._connected_alias:
await self._connected_alias.pop(alias).close()

def remove_connection(self, alias: str):
"""Removes connection from the registry.

Expand Down
Loading