localstack-python-client
localstack-python-client copied to clipboard
[Request] asyncio support
Would love to see:
- asyncio version of localstack_client
- monkeypatch aioboto3
clientandresource
Thanks :)
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!
Hi @hyunilmmt! Is there a chance you could give us some more details on this one?
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 ().
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.