peewee-async icon indicating copy to clipboard operation
peewee-async copied to clipboard

Using gather inside transaction may leads to errors

Open kalombos opened this issue 1 year ago • 3 comments

async with db.aio_atomic():
    await asyncio.gather(t1(), t2(), t3())

It seems fine if all tasks inside gather have no transaction but if t1 and t2 have aio_atomic statement inside it leads to mess of savepoints and errors.

kalombos avatar Jun 28 '24 13:06 kalombos

It seems fine if all tasks inside gather have no transaction

any exception in SQL STATEMENT will interrupt outer transaction and cause errors in other tasks too

spumer avatar Jun 28 '24 15:06 spumer

That's right. Thank you @spumer. As you said the solution is to add kind of forbid_subtask param to aio_atomic which forbids using of aio_atomic in subtasks.

kalombos avatar Jul 01 '24 05:07 kalombos

related #215 #123

kalombos avatar Jul 01 '24 05:07 kalombos