terricain / aioboto3

Wrapper to use boto3 resources with the aiobotocore async backend
Apache License 2.0
719 stars 74 forks source link

aioboto3 9.3.1 regression on long-running tasks #256

Closed dacevedo12 closed 2 years ago

dacevedo12 commented 2 years ago

Description

After updating from aioboto3 8.0.3 I got some errors with long-running tasks that execute many requests to dynamodb, such as:

botocore.exceptions.HTTPClientError: An HTTP Client raised an unhandled exception: Response payload is not completed, ConnectionResetError: Cannot write to closing transport and botocore.exceptions.HTTPClientError: An HTTP Client raised an unhandled exception: [Errno None] Can not write request body for https://dynamodb.us-east-1.amazonaws.com/

What I Did

I'm not sure exactly what triggered the errors other than using aioboto3 to perform multiple dynamodb operations my current setup looks like this

RESOURCE_OPTIONS = {
    "service_name": "dynamodb",
    "region_name": "us-east-1",
}
SESSION = aioboto3.Session()

async def query(...):
    async with SESSION.resource(**RESOURCE_OPTIONS) as resource:
        table_resource = await resource.Table("my_table")
        response = await table_resource.query(...)
        items = response.get("Items", [])
        while response.get("LastEvaluatedKey"):
            response = await table_resource.query(...)
            items += response.get("Items", [])
    return items

Note:

dacevedo12 commented 2 years ago

@terrycain looks like a regression on aiobotocore?

dacevedo12 commented 2 years ago

It seems aiobotocore 2.2.0 reintroduced a retry mechanism that could help solve this

Related #259

terricain commented 2 years ago

v9.5.0 should be out, try that :)