This demo runs the same FastAPI service on three event loops:
- stdlib
asyncio uvlooprsloop
When started with --event-loop rsloop, the demo explicitly enables
rsloop fast streams before importing the loop implementation.
If the Rust extension is not already built locally:
uv run --with maturin maturin develop --releaseThe demo itself uses temporary dependencies from uv, so nothing needs to be
added to the project package metadata.
From the repository root:
uv run --with fastapi --with uvicorn python demo/fastapi_service.py --event-loop asyncio --no-access-log
uv run --with fastapi --with uvicorn --with uvloop python demo/fastapi_service.py --event-loop uvloop --no-access-log
uv run --with fastapi --with uvicorn python demo/fastapi_service.py --event-loop rsloop --no-access-logService entrypoint: demo/fastapi_service.py
std-async is also accepted as an alias for stdlib asyncio:
uv run --with fastapi --with uvicorn --with uvloop python demo/fastapi_service.py --event-loop std-async/returns the selected loop and basic service info/healthreturns a simple readiness payload/sleep?delay=0.05exercises timer scheduling/fanout?tasks=500&delay=0exercises concurrent task scheduling/stream-loopback?roundtrips=100&payload_size=256exercisesasyncio.start_server()andasyncio.open_connection(), which usersloopfast streams inrsloopmode
Example:
curl http://127.0.0.1:8000/
curl "http://127.0.0.1:8000/fanout?tasks=1000&delay=0"
curl "http://127.0.0.1:8000/stream-loopback?roundtrips=200&payload_size=512"