Closed ekapratama93 closed 3 years ago
Here are my dependencies:
aioboto3==8.0.5
aiobotocore==1.0.4
aiohttp==3.6.2
boto3==1.12.32
botocore==1.15.32
s3transfer==0.3.3
Sorry I've taken so long to get back to this.
Its to do with how boto3 creates properties on the higher level service objects. As you call obj.metadata
it'll go and load the metadata for that object synchronously. Not really applicable to async so you need to await obj.metadata
as it returns a co-routine
so this snippet seems to work for me
import asyncio
import aioboto3
async def main():
async with aioboto3.resource('s3') as s3:
audio_bucket = await s3.Bucket('aioboto3-test-bucket')
async for file in audio_bucket.objects.all():
obj = await audio_bucket.Object(key=file.key)
obj_metadata = await obj.metadata
await obj.copy_from(CopySource={'Bucket':'aioboto3-test-bucket', 'Key':file.key}, TaggingDirective='REPLACE', MetadataDirective='REPLACE', Tagging="a=1", Metadata=obj_metadata)
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
Feel free to reopen this if your still having issues.
Description
I tried to update tags using Object.copy_from but got error
sys:1: RuntimeWarning: coroutine 'AIOBoto3ResourceFactory._create_autoload_property.' was never awaited
. Here is the error message from the code.What I Did