AnswerDotAI / AnswerDotAI/fasthtml
APIRouter sync wrapper breaks async handlers that use event-loop-bound clients
- Dominant language
- Jupyter Notebook
- Stars
- 7k
- Forks
- 319
- Avg merge
- 28m
- Merged PRs (30d)
- 3
Description
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.
Contributor guide
Research direction
Start at the APIRouter registration path and compare it with the native @rt app registration described in the issue. Reproduce an async handler using a uvicorn event-loop-bound client, then verify that APIRouter preserves coroutine execution rather than sending the handler through Starlette's threadpool.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100