- 
                Notifications
    You must be signed in to change notification settings 
- Fork 166
Closed
Description
We had a hard to debug issue when testing async sqlalchemy.
When running the following test
from sqlalchemy.sql import text
from sqlalchemy.ext.asyncio import create_async_engine
from sqlalchemy.pool import NullPool
engine = create_async_engine(
    "postgresql+asyncpg://user:password@localhost:5432/db_name", future=True#, poolclass=NullPool
)
async def test_echo():
    async with engine.begin() as conn:
        r = await conn.execute(text("SELECT 'hello' as echo"))
        assert r.scalar() == "hello"
async def test_echo2():
    async with engine.begin() as conn:
        r = await conn.execute(text("SELECT 'hello' as echo"))
        assert r.scalar() == "hello"
async def test_echo3():
    async with engine.begin() as conn:
        r = await conn.execute(text("SELECT 'hello' as echo"))
        assert r.scalar() == "hello"we would get two errors:
attached to a different loop
<class 'asyncpg.exceptions._base.InterfaceError'>: cannot perform operation: another operation is in progress
This is fixed by having a global event loop as suggested in #38 (comment). Should there maybe be a command line option to enable this?
I'm opening this issue, as the creator of sqlalchemy suggested to report this to the underlying asyncio runner. See MagicStack/asyncpg#863 (comment)
simon-liebehenschel, chris1248, alukach, OlegDokuchaev, zzzachzzz and 1 more
Metadata
Metadata
Assignees
Labels
No labels