python - aioboto3 parallel page fetching from s3 - Stack Overflow

admin2025-05-02  1

I have an s3 bucket. It contains many thousands of objects. I want to use a paginator to extract all the lists of object keys in parallel using asynchio and aioboto3.

Is this possible? It seems to not work. If it's not possible, then why?

This is what I tried that raises an exception:

async def parallel_pagination(bucket_name, bucket_path):
    async with aioboto3_session.client("s3") as aios3_client:
        paginator = aios3_client.get_paginator("list_objects_v2")
        page_iterator = paginator.paginate(Bucket=bucket_name, Prefix=bucket_path)
        coroutines = [page.get("Contents",[]) async for page in page_iterator]
        pages = await asyncio.gather(*coroutines)
        return pages
转载请注明原文地址:http://anycun.com/QandA/1746123347a91996.html