I am trying to use asyncio to run all the methods of a class. Here is a minimal code:
Class Reports:
def __init__(self, name):
self.name = name
async def func1(**kwargs):
await subfunc1
async def func2(**kwargs):
await subfunc2
report = Reports('dealer1)
func_list = ['func1', 'func2']
keyworded_args = {'arg1':arg1, 'arg2' : arg2}
futures = [exec('reports' + func(**keyworded_args)) for func in func_list]
loop = asyncio.get_event_loop()
loop.run_until_complete(futures)
This runs the functions in the exec statement during executing the list comprehension futures. What are the alternatives? There are more than 20 functions and the list keeps on increasing. Hence want a compact way to run all the methods of the class using asyncio.
I use python 3.6.8