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.
Consider the following simulation of concurrent access:
# pylint: skip-file
import asyncio
import os
from databases import Database
async def tx1(db):
async with db.transaction():
await db.execute("INSERT INTO foo VALUES (1)")
await asyncio.sleep(1.5)
async def tx2(db):
async with db.transaction():
await asyncio.sleep(0.5)
result = await db.execute("SELECT * FROM foo")
assert result is None, result
await asyncio.sleep(1)
async def main():
db = Database("postgresql://rdbms:rdbms@localhost")
await db.connect()
await db.execute("CREATE TABLE IF NOT EXISTS foo (bar int4)")
await db.execute("TRUNCATE foo CASCADE")
await asyncio.gather(
tx1(db.connection()),
tx2(db.connection())
)
if __name__ == '__main__':
asyncio.run(main())
This code should exit succesfully, but either fails with cannot perform operation: another operation is in progress (which is also weird because a new connection is requested) or at the assert statement. Please provide some clarification regarding the expected transactional behavior and isolation of this module.