Skip to content

APIRouter sync wrapper breaks async handlers that use event-loop-bound clients #923

Description

@lgs

Repro: define an async APIRouter handler that awaits/calls a client whose futures belong to the uvicorn loop, include the router, and invoke it. The wrapper is treated as sync and runs in Starlette's threadpool, producing no event loop / Future attached to a different loop failures. Registering the same handler through native @rt on the app preserves async execution. Full integration notes: https://github.com/lgs/iii-fasthtml-frontend/blob/main/docs/ARCHITECTURE.md#11-platform-quirks-discovered-all-worked-around-in-code. Expected: APIRouter preserves coroutine handlers.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions