How kludex/uvicorn works
Uvicorn is a Python ASGI server. The principal workflow is CLI invocation, configuration and application loading, listener startup, protocol handling of HTTP or WebSocket traffic, and ASGI messages exchanged with the application. Separate runtime branches cover lifespan, middleware, logging, and reload/worker process management. The README documents HTTP/1.1, HTTP/2, and WebSocket support; source excerpts and the SOURCE INDEX support the implementation links shown. Some wiring is unsampled, so uncertain links are omitted.
Main entry points: server.py Server and listeners · config.py Configuration and app loading · main.py CLI and run API · h11_impl.py HTTP/1.1 h11
Components 20
Entry and configuration
- CLI and run API
uvicorn/main.py - Configuration and app loading
uvicorn/config.py
Server runtime
- Server and listeners
uvicorn/server.py - Lifespan handling
uvicorn/lifespan/on.py
Connection protocols
- HTTP/1.1 h11
uvicorn/protocols/http/h11_impl.py - HTTP httptools
uvicorn/protocols/http/httptools_impl.py - HTTP/2
uvicorn/protocols/http/zttp_h2_impl.py - HTTP zttp
uvicorn/protocols/http/zttp_impl.py - WebSocket websockets
uvicorn/protocols/websockets/websockets_impl.py - WebSocket sans-I/O
uvicorn/protocols/websockets/websockets_sansio_impl.py - WebSocket wsproto
uvicorn/protocols/websockets/wsproto_impl.py
Runtime support
- ASGI types and messages
uvicorn/_types.py - HTTP flow control
uvicorn/protocols/http/flow_control.py - ASGI middleware
uvicorn/middleware - Event loop selection
uvicorn/loops/asyncio.py - Logging and access logs
uvicorn/logging.py
Process management
- Reload supervisors
uvicorn/supervisors/basereload.py - Worker processes
uvicorn/workers.py - Subprocess support
uvicorn/_subprocess.py
Other components
- ASGI application
Connections 31
- CLI and run API → Configuration and app loading: builds
uvicorn/main.py - CLI and run API → Server and listeners: starts
uvicorn/main.py - Configuration and app loading → ASGI application: loads
uvicorn/config.py - Server and listeners → Configuration and app loading: uses settings
uvicorn/server.py - Server and listeners → HTTP/1.1 h11: creates protocol
uvicorn/server.py - Server and listeners → HTTP httptools: creates protocol
uvicorn/server.py - Server and listeners → HTTP/2: creates protocol
uvicorn/server.py - Server and listeners → HTTP zttp: creates protocol
uvicorn/server.py - Server and listeners → WebSocket websockets: creates protocol
uvicorn/server.py - Server and listeners → WebSocket sans-I/O: creates protocol
uvicorn/server.py - Server and listeners → WebSocket wsproto: creates protocol
uvicorn/server.py - Server and listeners → Lifespan handling: runs lifecycle
uvicorn/server.py - HTTP/1.1 h11 → ASGI application: dispatches ASGI
uvicorn/protocols/http/h11_impl.py - HTTP httptools → ASGI application: dispatches ASGI
uvicorn/protocols/http/httptools_impl.py - HTTP/2 → ASGI application: dispatches ASGI
uvicorn/protocols/http/zttp_h2_impl.py - HTTP zttp → ASGI application: dispatches ASGI
uvicorn/protocols/http/zttp_impl.py - WebSocket websockets → ASGI application: dispatches ASGI
uvicorn/protocols/websockets/websockets_impl.py - WebSocket sans-I/O → ASGI application: dispatches ASGI
uvicorn/protocols/websockets/websockets_sansio_impl.py - WebSocket wsproto → ASGI application: dispatches ASGI
uvicorn/protocols/websockets/wsproto_impl.py - Configuration and app loading → ASGI middleware: configures
uvicorn/config.py - HTTP/1.1 h11 → HTTP flow control: uses flow control
uvicorn/protocols/http/h11_impl.py - HTTP httptools → HTTP flow control: uses flow control
uvicorn/protocols/http/httptools_impl.py - HTTP zttp → HTTP flow control: uses flow control
uvicorn/protocols/http/zttp_impl.py - HTTP/1.1 h11 → ASGI types and messages: uses message types
uvicorn/protocols/http/h11_impl.py - WebSocket sans-I/O → ASGI types and messages: uses message types
uvicorn/protocols/websockets/websockets_sansio_impl.py - Configuration and app loading → Event loop selection: selects loop
uvicorn/config.py - Server and listeners → Logging and access logs: logs runtime
uvicorn/server.py - CLI and run API → Reload supervisors: selects supervisor
uvicorn/main.py - Reload supervisors → Subprocess support: spawns process
uvicorn/supervisors/basereload.py - CLI and run API → Worker processes: selects workers
uvicorn/main.py - Worker processes → Server and listeners: runs server
uvicorn/workers.py