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

[Request] asyncio support #43

Open
hyunilmmt opened this issue Sep 14, 2022 · 4 comments
Open

[Request] asyncio support #43

hyunilmmt opened this issue Sep 14, 2022 · 4 comments

Comments

@hyunilmmt
Copy link

Would love to see:

  • asyncio version of localstack_client
  • monkeypatch aioboto3 client and resource

Thanks :)

@whummer
Copy link
Member

whummer commented Jan 24, 2023

Hi @hyunilmmt , thanks for reporting! Can you please share some details about your use case - can you share a small snippet or test case of an asyncio function that would make use of the client? I think we have a rough understanding - but it would be helpful for us to understand the requirements a bit better.. Thanks!

@alexrashed
Copy link
Member

Hi @hyunilmmt!
Is there a chance you could give us some more details on this one?

@mjpieters
Copy link

aioboto3 is the asyncio version of boto3. It'll need patching the same way boto3 is being patched. The use case is that any project using aioboto3 in async code can be tested the same way you test boto3 code.

e.g. using the sample function from the aioboto3 project:

async def main():
    session = aioboto3.Session()
    async with session.resource("s3") as s3:
        bucket = await s3.Bucket('mybucket')
        async for s3_object in bucket.objects.all():
            print(s3_object)

The Session() object there won't be patched even if you used localstack_client.patch.enable_local_endpoints ().

@mjpieters
Copy link

After a brief look at how enable_local_endpoints works, and at how aioboto3 defines the Session class you probably can apply the same patch to aioboto3 and have it work transparently.

Note that the Session.client object is now a client defined by aiobotocore, but it uses botocore.client.BaseClient as the base exactly the same way boto3 / botocore use it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants