terricain / aioboto3

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

S3 client->put_object not working #163

Closed pabloariasmora closed 5 years ago

pabloariasmora commented 5 years ago

Description

I have a method to upload data to s3 using put_object, but it failed giving a timeout to await.

What I Did

I was trying to look for an example that could help me to validate my algorithm but couldn't find it in the documentation.

Here is my def

import logging
import time
import aioboto3
import asyncio

logger = logging.getLogger(__name__)

async def upload_file_to_s3_async(bucket_name, key):
    async with aioboto3.client(
            's3',
            aws_access_key_id=<AWS ID>,
            aws_secret_access_key=<AWS-ACCESS-KEY>,
            use_ssl=False
    ) as client:
        start_time = time.time()
        logger.info('Starting Upload')
        await client.put_object(
            Bucket=bucket_name,
            Key=key,
            Body=b'Test Data'
        )
        logger.info('File Uploaded to S3 in {}'.format(time.time() - start_time))

async def main():
    await upload_file_to_s3_async('bucket_123', 'key/1/2/3')

loop = asyncio.get_event_loop()
loop.run_until_complete(main())

It hangs after logger.info('Starting Upload'), not sure why the put_object method is failing.

Exception been displayed aiohttp.client_exceptions.ServerTimeoutError: Timeout on reading data from socket

PD: I have the same implementation only on boto3 and is working.

terricain commented 5 years ago

try using aiobotocore.client as thats essentially whats being used. I would suspect the use_ssl=False is the issue here, is there any reason why you've disabled it?

pabloariasmora commented 5 years ago

Thanks for the reply,

I removed the flag, but still showing the same issue. I currently have the flag because my dev env has some issues with certificates, but I did tested with the flag in other environment without cert issues.

terricain commented 5 years ago

Are you sure you can hit S3 from where your running this as it works for me, although I'm on Linux I don't think being on windows would matter.

pabloariasmora commented 5 years ago

I did test using the boto3 implementation, from the same machine and worked, but this one was not able to do it. Probably is related with Windows in that case.

terricain commented 5 years ago

I'm closing this as a windows issue, if you can reproduce it on linux i'll look more into it.