AnyIO

High-level async concurrency and networking API that runs on both asyncio and Trio

Library
PyPI
v4.14.2
2,532stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
85/100Excellent
Development Activity100
Maintenance72
Community68
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
80/100Excellent
Architecture85
Code Quality88
Innovation78
Learning Curve68

AnyIO is a Python library that provides a single, high-level asynchronous programming API — structured concurrency with task groups, cancellation scopes, sockets, streams, synchronization primitives, and subprocess/thread offloading — that works identically whether the underlying event loop is asyncio or Trio. Rather than choosing between the two ecosystems, library authors can target AnyIO’s API once and let end users run their code on whichever backend they prefer, while application authors get Trio-style structured concurrency (task groups that guarantee child tasks finish or are cancelled before the parent scope exits) even when running on plain asyncio.

AnyIO is widely used as the concurrency layer underneath other popular async libraries (including Starlette/FastAPI’s test client and httpx’s async transport), because it removes the need for those projects to hand-write asyncio/Trio compatibility shims. It also ships a pytest plugin (anyio.pytest_plugin) for testing async code against both backends without duplicating test suites, and provides thread/subprocess/interpreter offloading helpers (to_thread, to_process, to_interpreter) for running blocking or CPU-bound work without blocking the event loop.

What You Get

  • Structured concurrency via task groups and cancellation scopes that guarantee child tasks complete or are cancelled before their parent scope exits
  • A unified socket/stream API for TCP, UDP, and Unix sockets that behaves identically on asyncio and Trio
  • Synchronization primitives (locks, semaphores, events, condition variables) usable from either backend
  • Thread, process, and subinterpreter offloading helpers (to_thread, to_process, to_interpreter) for running blocking work off the event loop
  • A pytest plugin for running the same async test suite against both asyncio and Trio backends

Common Use Cases

  • Library authors writing async I/O code once that needs to run on both asyncio and Trio user applications
  • Application developers wanting Trio-style structured concurrency (guaranteed task cleanup) while staying on the asyncio ecosystem
  • Frameworks (e.g. web frameworks, HTTP clients) using AnyIO internally as their concurrency primitive layer instead of hand-rolling asyncio/Trio shims
  • Offloading blocking or CPU-bound work (file I/O, C extensions) from async code via to_thread/to_process without blocking the event loop
  • Testing async libraries against both backends in a single pytest suite via the built-in anyio pytest plugin

Under The Hood

Architecture AnyIO’s public API in src/anyio/_core is backend-agnostic; at runtime it dispatches to one of two backend implementations in src/anyio/_backends_asyncio.py (which adapts native asyncio primitives, adding structured-concurrency semantics asyncio lacks natively) or _trio.py (a thinner pass-through, since Trio already implements structured concurrency natively). This split lets AnyIO present one API while each backend module handles the real differences in cancellation semantics, task scheduling, and socket implementation between the two runtimes.

Tech Stack Pure Python (3.10+), using setuptools/setuptools_scm for packaging, with idna as its only hard runtime dependency (plus conditional exceptiongroup/typing_extensions backports for older Python versions) and trio as an optional extra for the Trio backend. Ships a py.typed marker for full type-checker support.

Code Quality The tests/ directory (over 15,000 lines including a dedicated streams subdirectory) covers task groups, cancellation, sockets, subprocesses, synchronization, deprecations, and the pytest plugin itself, and both AGENTS.md and CLAUDE.md files in the repo root document contributor/agent conventions directly — an unusually explicit level of process documentation for a library of this size. The project is fully type-annotated and uses blockbuster (a dev dependency) to detect accidental blocking calls inside async code during its own test suite.

API Design The core primitives — anyio.create_task_group(), anyio.CancelScope, anyio.to_thread.run_sync() — closely mirror Trio’s already well-regarded structured-concurrency API, so developers familiar with Trio (or who read AnyIO’s docs) get a consistent mental model regardless of which backend actually executes their code. This deliberate API alignment with Trio, rather than asyncio’s lower-level primitives, is what allows AnyIO to add real cancellation guarantees on top of asyncio without exposing two divergent programming models.

Used by 22 apps in this directory

Python
100%
Apache 2.0

Agno

Devops · AI Development · Automation

41,774

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

View details
93
Repo Health
87
Technical
67
Dependency
Built with
Python100%
Updated today
Python
59%
Apache 2.0

argilla

AI Development · Data Engineering

5,081

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
63
Dependency
Built with
Python59%
Jupyter Notebook21%
Updated 2 days ago
C++
69%
Apache 2.0

ClickHouse

Databases · Analytics · Data Engineering

49,325

Open-source column-oriented database that delivers real-time analytical queries on petabyte-scale data with millisecond latency.

View details
95
Repo Health
90
Technical
68
Dependency
Built with
C++69%
Python13%
Updated today
Go
32%
Apache 2.0

CubeSandbox

Developer Tools · Security · AI Agents

11,247

Instant, concurrent, hardware-isolated MicroVM sandboxes for AI agents — E2B-API compatible, sub-60ms cold starts, and a built-in zero-trust egress proxy, all self-hostable at scale.

View details
83
Repo Health
88
Technical
63
Dependency
Built with
Go32%
Rust31%
C21%
Updated today
Python
99%
MIT

deepagents

AI Agents · AI Development

27,919

The batteries-included Python agent harness — planning, sub-agents, filesystem, shell, memory, and skills bundled in, built on LangGraph.

View details
88
Repo Health
83
Technical
74
Dependency
Built with
Python99%
Updated today
Go
42%
Apache 2.0

e2a

AI Agents · Automation

182

Give your AI agents a real, authenticated email address — with SPF/DKIM-verified inbound, HMAC-signed delivery, WebSocket fan-out, and human-in-the-loop approval built in.

View details
78
Repo Health
80
Technical
76
Dependency
Built with
Go42%
TypeScript28%
Python15%
Updated today
Python
63%
Apache 2.0

GPT Researcher

Productivity · AI Assistants

29,039

The pioneering open-source autonomous AI agent that conducts deep, multi-source research and produces citation-backed reports exceeding 2,000 words — faster and more reliably than any human researcher.

View details
88
Repo Health
91
Technical
64
Dependency
Built with
Python63%
TypeScript23%
Updated 1 months ago
TypeScript
91%
Apache 2.0

Helicone

Monitoring · AI Development · Analytics

6,083

An open-source AI gateway and LLM observability platform that routes requests to 100+ models while logging cost, latency, and full traces for every call.

View details
62
Repo Health
81
Technical
66
Dependency
Built with
TypeScript91%
Updated 3 days ago
Rust
72%
Other

iii

Developer Tools · Devops

18,604

Compose, extend, and observe every backend service in real time using three primitives: Workers, Functions, and Triggers.

View details
86
Repo Health
85
Technical
69
Dependency
Built with
Rust72%
TypeScript17%
Updated yesterday

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

Search