terricain / aioboto3

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

upload_fileobj does not execute abort_multipart_upload if an error occurs while reading the file #209

Closed AlexeyBerezhnoy closed 3 years ago

AlexeyBerezhnoy commented 4 years ago

Description

upload_fileobj does not execute abort_multipart_upload if an error occurs while reading the file.
I expect abort_multipart_upload if upload_fileobj aborts

What I Did

ENDPOINT_URL = ''
AWS_ACCESS_KEY_ID = ''
AWS_SECRET_ACCESS_KEY = ''
Bucket = ''

async def test():
    session = aioboto3.session.Session(aws_access_key_id=AWS_ACCESS_KEY_ID, aws_secret_access_key=AWS_SECRET_ACCESS_KEY)
    async with session.client(service_name='s3', endpoint_url=ENDPOINT_URL) as s3:
        response = await s3.list_multipart_uploads(Bucket=Bucket)
        print(len(response['Uploads']))

        try:
            await s3.upload_fileobj(broken_file, Bucket, 'broken2')
        finally:
            response = await s3.list_multipart_uploads(Bucket=Bucket)
            print(len(response['Uploads']))

asyncio.run(test())
terricain commented 3 years ago

Should be fixed in the next release

terricain commented 3 years ago

8.2.0 released