You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 19, 2025. It is now read-only.
I've noticed that if one of my tests fails, every next test will fail with error from async with database claiming that connection is still on.
Upon closer look I've found out that first tests failure triggers transaction's rollback which sends rollback to the database.
However asyncpg.exceptions._base.InterfaceError: cannot perform operation: another operation is in progress will be raised in response to this, resulting in invalid state:
is_connected = True
_transaction_stack = []
This state can't be fixed other by monkeypatching connection object, as trying to call disconnect() will try to pop item from empty _transaction_stack, causing other exception.
Min repro:
database = Database(url="...", force_rollback=True)
async with database:
await raise_exception()
async with database: # this will crash because previous database connection was not cleaned up completely.
database.exec("...")