Running independent endpoint requests on parallel in Python

188 Views Asked by At

I have a functions which is being accessed using REST API methodology by Fast API. Right now, when user request my endpoints, each method is processed synchronously.

async def endpoint1(param1, param2):
    return await some_async_method1()
async def endpoint2(param1, param2):
    return await some_async_method2()

etc.

I have tried asyncio gather, however, I do not know when or which endpoints will be called. Thus, I cannot give list of methods to the asyncio gather method.

I have tried ThreadPoolExecutor, I kept loosing the return values.

0

There are 0 best solutions below