using list of async funcs in async for

60 Views Asked by At

I have function that execute all functions in list like

async def db_create():
    x = [users_table_create, element_table_create]
    async with pool.acquire() as con:
        async for creation_func in x:
            async with con.transaction() as tr:
                try:
                    await creation_func(con)
                    await tr.commit()

                except Exception:
                    tr.rollback()

funcs:

async def elements_table_create(con) -> NoReturn:
    await con.execute("CREATE TABLE elements(...);")

async def users_table_create(con) -> NoReturn:
    await con.execute("CREATE TABLE users(...);")

But I got exception that I need something with __aiter__, not list

0

There are 0 best solutions below