1. License
“Permission is hereby granted, free of charge, to any person obtaining a copy”
MIT allows use in paid and closed-source products.
github.com/agronholm/anyio/blob/master/LICENSE3. Used by agents' projects
Dependency in 92 public GitHub projects set up for AI coding agents that we scanned (1.5%).
4. Agent access
Agent skills for this library in the skills catalog; community skills are written by others, read them before you install.
From the package registry and GitHub, checked daily; card checked Nov 11, 2026. Tap a verdict to see its source.How we checkedReport an error
What AnyIO does
AnyIO is a free Python library for code that waits a lot, such as network calls, so it can do many of those waits at the same time. It adds safe task groups, timeouts and a way to run slow ordinary code in the background. Code written with it runs on Python's built-in asyncio or on Trio without changes.
What people build with it
Run slow calls side by side
Your app fetches three files or pages; instead of waiting for each in turn, it starts all three and waits once.
Give up on a stuck call
A call to an outside service hangs; your code stops waiting after a set time and goes on.
Use blocking code without freezing
An old library or an image resize blocks; running it in a worker thread keeps your app answering other requests.
One library for asyncio and Trio
You publish a package and do not want to force users onto one async system; AnyIO code runs on both.
Test async code with pytest
Your tests call async functions; the plugin that comes with AnyIO runs them, with nothing extra to install.
Start a server, then use it
A test or a dev script starts a local service and waits until it is listening before it connects.
AnyIO popularity
Gid Score measures public popularity and activity, not quality. How the Gid Score is calculated
How AnyIO is used
- AnyIO is a dependency in 92 of the 6,258 public GitHub projects set up for AI coding agents that we scanned (5.7% of the 1,623 Python ones), #14 of 126 in http clients and networking.
- Counting the projects our scan samples by dependency (Solana 3,067, Ethereum and EVM 1,774, 3D and games 3,130, agent frameworks and SDKs 13,750), it appears in 1,390; those are left out of every share on this page.
- The most used alternative in our scan is httpx (280 projects).
- Projects that use it most often also use Pydantic (82.6%), Uvicorn (81.5%), python-dotenv (72.8%).
By coding agent
Often used with
More about AnyIO
Funding
- Tidelift: https://tidelift.com/funding/github/pypi/anyio
More in HTTP clients and networking
Alternatives
AnyIO This page
Pick Trio when you are fine with one async system and want its structured concurrency directly.
Pick Asyncer when you want a thin, typed helper layer on top of AnyIO for mixing async and regular code.
Pick gevent for older code written without async and await that should still handle many connections.
Modern Python HTTP client with async support, replacing the standard requests library.
Async HTTP client/server framework for Python with WebSocket support.
HTTP client with thread-safe connection pooling, file uploads and advanced features.
Get started
Tell your AI assistant
“Use anyio 4.16.0 (Python 3.10+) for concurrency: run independent awaits in anyio.create_task_group(), wrap slow calls in with anyio.fail_after(seconds), run blocking functions with await anyio.to_thread.run_sync(fn), and catch task group errors with except* because AnyIO 4 raises ExceptionGroup.”
Install it (Python 3.10 or newer); add the trio extra only if you want Trio.
pip install anyioWrite an async main function and start it with anyio.run.
from anyio import run async def main() -> None: print("Hello, world!") run(main)Start several tasks in a task group; the block ends when all of them are done.
async with create_task_group() as tg: for num in range(5): tg.start_soon(sometask, num)
Mistakes to avoid
AnyIO 4 wraps even a single error in an ExceptionGroup; in our run except ValueError did not catch it.
Timeout scopes are plain context managers, not async ones.
The argument was renamed in AnyIO 4.1 and the old name is deprecated.
Blocking calls stop every other task until they return.
The two plugins in auto mode conflict.
Questions
Do I need Trio to use it?
No. It runs on Python's built-in asyncio by default; Trio is an optional extra.
Why does except ValueError not catch the error from my task group?
Since AnyIO 4 the error comes inside an ExceptionGroup. Use except* ValueError on Python 3.11+, or the exceptiongroup backport.
What is the difference between move_on_after and fail_after?
move_on_after quietly leaves the block when time is up; fail_after raises a TimeoutError.
Can I mix it with plain asyncio code?
Yes. It can be adopted bit by bit and blends in with the libraries of the async system you use.