05bit / peewee-async

Asynchronous interface for peewee ORM powered by asyncio
http://peewee-async-lib.readthedocs.io
MIT License
733 stars 100 forks source link

Using gather inside transaction may leads to errors #260

Open kalombos opened 4 months ago

kalombos commented 4 months ago
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.

spumer commented 4 months ago

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

kalombos commented 4 months ago

That's right. Thank you @spumer

kalombos commented 4 months ago

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 commented 4 months ago

related #215 #123