Uvicorn

A lightning-fast ASGI server for Python, built on uvloop and httptools.

Tool
PyPI
v0.54.0
10,993 stars
BSD 3-Clause License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
91 /100 Excellent
Development Activity 100
Maintenance 96
Community 68
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
89 /100 Excellent
Architecture 90
Code Quality 92
Innovation 88
Learning Curve 85

Uvicorn is an ASGI (Asynchronous Server Gateway Interface) server implementation for Python. Where WSGI servers like Gunicorn only handle synchronous request/response cycles, Uvicorn provides the low-level server loop that async Python web frameworks need to support long-lived connections such as WebSockets and long-polling HTTP, plus the standard startup/shutdown lifespan protocol.

It ships as both a CLI (uvicorn app:app) and a programmatic API (uvicorn.run(app)), and is the de facto standard server underneath FastAPI, Starlette, and other ASGI frameworks. Installing the standard extras pulls in Cython-accelerated dependencies — uvloop for the event loop and httptools for HTTP parsing — for substantially better throughput than the pure-Python fallback.

What You Get

  • An ASGI-compliant HTTP/1.1 and WebSocket server runnable via CLI (uvicorn app:app) or embedded with uvicorn.run()
  • Pluggable protocol implementations — h11/httptools for HTTP, websockets/wsproto for WebSockets, asyncio/uvloop for the event loop
  • Application lifespan protocol support for startup/shutdown hooks
  • A --reload development mode backed by watchfiles for fast local iteration
  • Multi-worker process supervision and graceful shutdown handling for production deployments
  • SSL/TLS termination, Unix domain socket and file-descriptor binding for containerized and proxied setups

Common Use Cases

  • Running a FastAPI or Starlette application in local development with hot reload
  • Serving an ASGI app in production behind a reverse proxy such as Nginx or Traefik
  • Powering WebSocket-based realtime features (chat, live updates, streaming responses) in async Python apps
  • Embedding a server directly inside a script or worker process via uvicorn.run() instead of a CLI invocation
  • Running multiple worker processes for CPU-bound concurrency alongside async I/O concurrency

Under The Hood

Architecture Uvicorn’s core execution path runs through uvicorn/main.py (the CLI entry main() and the run() convenience function), which builds a Config object (uvicorn/config.py) from CLI flags or kwargs, resolving protocol implementations (h11/httptools for HTTP, websockets/wsproto for WebSockets) and loop factories (asyncio/uvloop) via dotted-path lookups in dictionaries like HTTP_PROTOCOLS, WS_PROTOCOLS, and LOOP_FACTORIES. The Server class (uvicorn/server.py) owns the actual asyncio event loop: run() calls asyncio_run(self.serve()), which creates one asyncio.Protocol instance per connection via loop.create_server(create_protocol, ...), tracks connection and task state in a shared ServerState, and drives a lifespan handler (uvicorn/lifespan/on.py or off.py) that sends ASGI lifespan startup/shutdown events to the application before and after serving. Multi-worker setups (uvicorn/supervisors/multiprocess.py) fork worker processes that share listening sockets, while uvicorn/supervisors/basereload.py and watchfilesreload.py implement the --reload development loop.

Tech Stack Written in modern Python (3.10+) targeting CPython and PyPy, with click for CLI argument parsing and h11 as its baseline pure-Python HTTP/1.1 parser (both required dependencies). The optional standard extra pulls in Cython-accelerated httptools for HTTP parsing, uvloop for a faster event loop (non-Windows only), websockets/wsproto for WebSocket protocol handling, watchfiles for reload-mode file watching, python-dotenv for --env-file support, and PyYAML for YAML logging config. Build tooling is hatchling with uv for dependency/dev-env management (a committed uv.lock), ruff for linting, mypy for type checking, and pytest (with pytest-xdist and pytest-codspeed for benchmarks) for testing.

Code Quality The tests/ directory contains 38 test files covering protocols, supervisors, middleware, and the importer, with pytest-mock and trustme (for TLS test certs) as dev dependencies, and coverage is configured with fail_under = 100 in pyproject.toml — an unusually strict bar signaling a mature, disciplined test suite. Source files use full type annotations (from __future__ import annotations, TYPE_CHECKING guards for expensive imports like protocol implementations in server.py), and mypy runs as part of CI. Naming and module layout are consistent, with one file per protocol/loop/supervisor variant, and error handling in server.py’s shutdown()/_wait_tasks_to_complete() explicitly bounds graceful-shutdown waits with asyncio.wait_for and a timeout, falling back to task cancellation rather than hanging indefinitely.

API Design Uvicorn’s public surface is intentionally small: a Config object, a Server class, and a run() convenience function that most users never go beyond. Getting started is a single line — uvicorn.run(app) or uvicorn app:app from the CLI — with sensible defaults (auto-detecting the best available HTTP/WS/loop implementation) and progressive disclosure via CLI flags or Config kwargs for anything more advanced (SSL, workers, reload, logging). Documentation is thorough (a full mkdocs site with settings/concepts/deployment pages under docs/), and CLI help text is generated from the same Config definitions the programmatic API uses, keeping the two surfaces consistent.

Used by 83 apps in this directory

Python
67%
Apache 2.0

Agent Control

AI Agents

314

An open-source runtime control plane for AI agents — define safety guardrails once, apply them across agents built on LangChain, CrewAI, Google ADK, or AWS Strands, and update controls without redeploying code.

View details
74
Repo Health
71
Technical
67
Dependency
Built with
Python 67%
TypeScript 32%
Updated 4 days ago
Python
99%
MIT

Agent Lightning

AI Development

18,515

A Microsoft-built training framework that optimizes AI agents with reinforcement learning, automatic prompt optimization, or supervised fine-tuning — with near-zero code changes to your existing agent, in any framework.

View details
85
Repo Health
68
Technical
69
Dependency
Built with
Python 99%
Updated 4 days ago
TypeScript
56%
Other

agenta

AI Development · Developer Tools · Devops

4,788

The open-source LLMOps platform unifying prompt engineering, evaluation, and observability for teams building reliable LLM applications.

View details
91
Repo Health
77
Technical
67
Dependency
Built with
TypeScript 56%
Python 39%
Updated 5 days ago
Python
100%
Apache 2.0

Agno

AI Development · Automation · Devops

42,358

Build, run, and manage agent platforms with a full production stack — SDK, runtime, and control plane included.

View details
93
Repo Health
87
Technical
66
Dependency
Built with
Python 100%
Updated 4 days ago
Python
89%
Apache 2.0

Apache Airflow

Data Engineering

46,995

Define, schedule, and monitor complex data workflows as Python code — with a powerful UI, 80+ provider integrations, and battle-tested scalability across thousands of production deployments.

View details
96
Repo Health
89
Technical
64
Dependency
Built with
Python 89%
Updated 4 days ago
Python
59%
Apache 2.0

argilla

AI Development · Data Engineering

5,125

Collaborate on high-quality AI training data with a self-hosted annotation platform built for LLMs, NLP, and multimodal models.

View details
65
Repo Health
81
Technical
61
Dependency
Built with
Python 59%
Jupyter Notebook 21%
Updated 1 weeks ago
Python
59%
Other

Arkon

AI Assistants · Knowledge Management · Mcp

1,463

Self-hosted enterprise AI knowledge hub that compiles internal docs into a scoped, reviewable wiki and serves it to Claude and other LLMs through an MCP server.

View details
46
Repo Health
74
Technical
70
Dependency
Built with
Python 59%
TypeScript 41%
Updated 4 months ago
Python
92%
Apache 2.0

ART

AI Development

10,779

Give your LLM agents on-the-job training—ART lets you apply GRPO reinforcement learning to any multi-step agentic workflow with minimal code changes.

View details
85
Repo Health
82
Technical
73
Dependency
Built with
Python 92%
Updated 5 days ago
Python
55%
Other

authentik

Authentication · Security

25,758

The self-hosted Identity Provider that replaces Okta, Auth0, and Entra ID with a unified SSO platform supporting SAML, OAuth2/OIDC, LDAP, RADIUS, and WebAuthn.

View details
92
Repo Health
81
Technical
66
Dependency
Built with
Python 55%
TypeScript 36%
Updated 4 days ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers