Closed jcf-dev closed 3 years ago
try changing
s3_client = await s3()
# to
async with (await s3()) as s3_client:
blah everything else indented
you could drop the async def off the s3() function and then do
async with s3() as s3_client:
blah everything else indented
For using fastapi, I've not used it but i'd say you probably want the s3 client as a dependency declared something like
async def get_s3():
async with aioboto3.client('s3', blah) as client:
yield client
Though this might create the client on every request, ideally you'd want to create the client once, and then just reference that in every request (as long as you dont close the client)
Okay, now I get it. Thank you very much!
Description
I'm trying to use this package in my FastAPI app (to make everything async); however, I can't get this working. Here is a sample of my code.
api.py
files.py
I'm getting this error:
The error says that I need to await something. I've also tried using AioBaseClient. I would greatly appreciate it if you can point out the part I've been doing wrong. Thanks!