aio-libs / aiobotocore

asyncio support for botocore library using aiohttp
https://aiobotocore.aio-libs.org
Apache License 2.0
1.18k stars 182 forks source link

Upload to non-existing bucket appears to hang #645

Closed dimaqq closed 5 years ago

dimaqq commented 5 years ago

Environment:

Differential diagnosis:

Apologies that I'm not yet able to test against real S3 and cannot exclude minio as culprit.

Code snippet:

def client():
    return aiobotocore.get_session().create_client(
        "s3",
        endpoint_url=f"http://{os.environ.get('STORAGE_HOST', '???')}:9000",
        aws_access_key_id=os.environ.get("STORAGE_ACCESS_KEY", "???"),
        aws_secret_access_key=os.environ.get("STORAGE_SECRET_KEY", "???"),
    )

async def some_endpoint():
    some_bucket = "images"  # bucket must exist, else we hang...
    key = secrets.token_hex(8)

    async with client() as c:
        await c.put_object(Bucket=some_bucket, Key=key, Body=upload.read())
softwarengineer2 commented 5 years ago

Hi, @dimaqq

Can you try to use it with try-except :

def client():
    return aiobotocore.get_session().create_client(
        "s3",
        endpoint_url=f"http://{os.environ.get('STORAGE_HOST', '???')}:9000",
        aws_access_key_id=os.environ.get("STORAGE_ACCESS_KEY", "???"),
        aws_secret_access_key=os.environ.get("STORAGE_SECRET_KEY", "???"),
    )

async def some_endpoint():
    some_bucket = "images"  # bucket must exist, else we hang...
    key = secrets.token_hex(8)

    async with client() as c:
        try:
            await c.put_object(Bucket=some_bucket, Key=key, Body=upload.read())
        except Exception as e:
            print(e)
dimaqq commented 5 years ago

Hi, sorry, I moved on to another project and will not be able to test this. I'm pretty sure no exception was raised as that would generate an HTTP 400 response.

thehesiod commented 5 years ago

please state what botocore version you had, this is critically important

thehesiod commented 5 years ago

also can you provide full test-case? I can implement something but won't necessarily be what your issue is. Given you say this is happening in docker please provide dockerfile.

thehesiod commented 5 years ago

going to close as @dimaqq is unable to re-test and unable to exclude minio as culprit nor uvloop. Feel free to re-open if you have more information.