Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion fastapi_sqla/_pytest_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,9 @@ def async_sqlalchemy_url(db_url):

@fixture
def async_engine(async_sqlalchemy_url):
return create_async_engine(async_sqlalchemy_url)
engine = create_async_engine(async_sqlalchemy_url)
yield engine
engine.dispose()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On your notion page your context is anasync fixture`.

The engine.dispose() will just block on this sync fixture context or behind the scene a future/promise is run and will be completed at some point in time ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change the fixture to an async one and await the dispose call:

    @fixture
    async def async_engine(async_sqlalchemy_url):
        engine = create_async_engine(async_sqlalchemy_url)
        yield engine
        await engine.dispose()

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be awaited? IIUC it's an async function

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


@fixture
async def async_sqla_connection(async_engine):
Expand Down