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: remove async function in AsyncClient connection initialization #2487

Merged
merged 1 commit into from
Dec 20, 2024

Conversation

brcarry
Copy link
Contributor

@brcarry brcarry commented Dec 20, 2024

  • Move check for channel ready and identifier interceptor setup before each query call instead of during the AsyncClient connection initialization

- Move check for channel ready and identifier interceptor setup before each query call instead of during the AsyncClient connection initialization

Signed-off-by: Ruichen Bao <[email protected]>
@czs007
Copy link
Contributor

czs007 commented Dec 20, 2024

/approve

Copy link
Contributor

@XuanYang-cn XuanYang-cn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please try a class decorator to reduce repeating codes like this:

import asyncio

class AsyncPreMethodDecoratorMeta(type):
    async def __new__(mcs, name, bases, attrs):
        for attr_name, attr_value in attrs.items():
            if asyncio.iscoroutinefunction(attr_value):
                async def wrapper(*args, **kwargs):
                    # Your asynchronous pre-method logic here
                    print(f"Before {attr_name}")
                    return await attr_value(*args, **kwargs)
                attrs[attr_name] = wrapper
        return type.__new__(mcs, name, bases, attrs)

class AsyncMyClass(metaclass=AsyncPreMethodDecoratorMeta):
    async def async_method1(self):
        print("Async Method 1")

    async def async_method2(self):
        print("Async Method 2")

async def main():
    obj = AsyncMyClass()
    await obj.async_method1()
    await obj.async_method2()

asyncio.run(main())

@XuanYang-cn
Copy link
Contributor

This is not a blocking request change
/lgtm
/approve

@sre-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: brcarry, czs007, XuanYang-cn

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@sre-ci-robot sre-ci-robot merged commit 0d53a32 into milvus-io:master Dec 20, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants