Skip to content

FastAPI sync endpoints & sync/async co-use #381

@tuukkamustonen

Description

@tuukkamustonen

The docs instruct to use create_async_container but it won't work with sync endpoints.

You'll end up awaiting for sync function in https://github.com/reagento/dishka/blob/develop/src/dishka/integrations/base.py#L207

The lib hard-codes is_async=True in https://github.com/reagento/dishka/blob/develop/src/dishka/integrations/fastapi.py#L47

Are sync endpoints simply not supported?

In general, how can I use same container in both sync and async contexts? Consider creating an async container for FastAPI, but then tests are written as sync, and you want to access the same container from there - but can't call async AsyncContainer.get from sync method.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestintegrationsFramework integrations part

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions