run_until_complete ( go ()) Context Manager Examples from contextlib import AsyncExitStack from ssion import AioSession # How to use in existing context manager class Manager : def _init_ ( self ): self. delete_object ( Bucket = bucket, Key = key ) print ( resp ) loop = asyncio. get ( 'Contents', ): print ( c ) # delete object from s3 resp = await client. paginate ( Bucket = bucket, Prefix = folder ): for c in result. get_paginator ( 'list_objects' ) async for result in paginator. read () = data # list s3 objects using paginator paginator = client. get_object ( Bucket = bucket, Key = key ) # this will ensure the connection is correctly re-used/closed async with response as stream : assert await stream. get_object_acl ( Bucket = bucket, Key = key ) print ( resp ) # get object from s3 response = await client. put_object ( Bucket = bucket, Key = key, Body = data ) print ( resp ) # getting s3 object properties of file we just uploaded resp = await client. create_client ( 's3', region_name = 'us-west-2', aws_secret_access_key = AWS_SECRET_ACCESS_KEY, aws_access_key_id = AWS_ACCESS_KEY_ID ) as client : # upload object to amazon s3 data = b ' \x01 ' * 1024 resp = await client. format ( folder, filename ) session = get_session () async with session. Install $ pip install aiobotocore Basic Example import asyncio from ssion import get_session AWS_ACCESS_KEY_ID = "xxx" AWS_SECRET_ACCESS_KEY = "xxx" async def go (): bucket = 'dataintake' filename = 'dummy.bin' folder = 'aiobotocore' key = ' '. This library is a mostly full featured asynchronous version of botocore. Async client for amazon services using botocore and aiohttp/ asyncio.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |