1

The below function is calling the create_presigned_url but I am getting an error in await.

 def getPreSignedURL(request: Request, file: UploadFile = File(...) ):
       resp = await create_presigned_url(request,file)
       return resp

this is an async function which I want to call

async def create_presigned_url(bucket_name, object_name, expiration=3600):
---
return response
sakshi singhal
  • 101
  • 2
  • 9

1 Answers1

6

Hope this helps. Example of calling async function from regular function:

import asyncio

loop = asyncio.get_event_loop()


async def demo(name):
    return f"hello {name}"


def main():
    result = loop.run_until_complete(demo("world"))
    print(result)


if __name__ == '__main__':
    main()
tomarv2
  • 753
  • 3
  • 14