{
 "kind": "tool",
 "slug": "anyio",
 "path": "tools/anyio/",
 "name": "AnyIO",
 "maker": null,
 "density": "full",
 "crumbs": [
  [
   "Tools",
   "tools/"
  ],
  [
   "HTTP clients and networking",
   "tools/http-clients/"
  ]
 ],
 "lead": "Run many waiting tasks at once in Python.",
 "chips": [
  {
   "label": "HTTP clients and networking",
   "path": "tools/http-clients/"
  },
  {
   "label": "PYPI"
  }
 ],
 "primary": {
  "label": "Copy install command",
  "copy": "pip install anyio"
 },
 "links": [
  {
   "label": "GitHub",
   "href": "https://github.com/agronholm/anyio"
  }
 ],
 "track": "New versions, deprecation and license changes on your dashboard",
 "verdicts": [
  {
   "key": "license",
   "label": "License",
   "value": "MIT",
   "status": "yes",
   "sub": "Use it in paid apps",
   "quote": "Permission is hereby granted, free of charge, to any person obtaining a copy",
   "note": "MIT allows use in paid and closed-source products.",
   "src": "https://github.com/agronholm/anyio/blob/master/LICENSE"
  },
  {
   "key": "maint",
   "label": "Maintained",
   "value": "Maintained",
   "status": "yes",
   "sub": "Last change Nov 24, 2026",
   "note": "Latest GitHub release Nov 1, 2026. ",
   "src": "https://github.com/agronholm/anyio"
  },
  {
   "key": "pop",
   "label": "Used by agents' projects",
   "value": "92 projects",
   "status": "info",
   "sub": "#14 of 126 in its category",
   "note": "Dependency in 92 public GitHub projects set up for AI coding agents that we scanned (1.5%).",
   "src": null
  },
  {
   "key": "agent",
   "label": "Agent access",
   "value": "Install only",
   "status": "info",
   "sub": null,
   "note": "Agent skills for this library in the skills catalog; community skills are written by others, read them before you install.",
   "src": null
  }
 ],
 "vfoot": "From the package registry and GitHub, checked daily; card checked Nov 11, 2026.",
 "blocks": [
  {
   "id": "overview",
   "nav": "Overview",
   "h2": "What AnyIO does",
   "parts": [
    {
     "t": "prose",
     "text": "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."
    },
    {
     "t": "h3",
     "text": "What people build with it"
    },
    {
     "t": "uses",
     "items": [
      {
       "title": "Run slow calls side by side",
       "text": "Your app fetches three files or pages; instead of waiting for each in turn, it starts all three and waits once.",
       "idea": false
      },
      {
       "title": "Give up on a stuck call",
       "text": "A call to an outside service hangs; your code stops waiting after a set time and goes on.",
       "idea": false
      },
      {
       "title": "Use blocking code without freezing",
       "text": "An old library or an image resize blocks; running it in a worker thread keeps your app answering other requests.",
       "idea": false
      },
      {
       "title": "One library for asyncio and Trio",
       "text": "You publish a package and do not want to force users onto one async system; AnyIO code runs on both.",
       "idea": false
      },
      {
       "title": "Test async code with pytest",
       "text": "Your tests call async functions; the plugin that comes with AnyIO runs them, with nothing extra to install.",
       "idea": false
      },
      {
       "title": "Start a server, then use it",
       "text": "A test or a dev script starts a local service and waits until it is listening before it connects.",
       "idea": false
      }
     ]
    }
   ]
  },
  {
   "id": "popularity",
   "nav": "Popularity",
   "h2": "AnyIO popularity",
   "parts": [
    {
     "t": "stats",
     "items": [
      {
       "n": "73",
       "of": "/ 100",
       "l": "Gid Score, #272 overall"
      },
      {
       "n": "261M",
       "l": "downloads a week, pypi"
      },
      {
       "n": "2,572",
       "l": "GitHub stars"
      },
      {
       "n": "92",
       "l": "agent projects use it"
      }
     ]
    },
    {
     "t": "small",
     "text": "Gid Score measures public popularity and activity, not quality.",
     "link": "How the Gid Score is calculated",
     "path": "tools/top/"
    }
   ]
  },
  {
   "id": "usage",
   "nav": "How it is used",
   "h2": "How AnyIO is used",
   "parts": [
    {
     "t": "list",
     "items": [
      "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%)."
     ]
    },
    {
     "t": "h3",
     "text": "By coding agent"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "50 projects, 1.6%",
       "v": "GitHub Copilot",
       "path": "agents/github-copilot/"
      },
      {
       "l": "49 projects, 1.5%",
       "v": "Claude Code",
       "path": "agents/claude-code/"
      },
      {
       "l": "31 projects, 1.3%",
       "v": "Cursor",
       "path": "agents/cursor/"
      },
      {
       "l": "10 projects, 3.0%",
       "v": "OpenClaw",
       "path": "agents/openclaw/"
      },
      {
       "l": "6 projects, 1.3%",
       "v": "Gemini CLI",
       "path": "agents/gemini-cli/"
      },
      {
       "l": "5 projects, 1.1%",
       "v": "OpenAI Codex",
       "path": "agents/openai-codex/"
      }
     ]
    },
    {
     "t": "h3",
     "text": "Often used with"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "In 82.6% of its projects",
       "v": "Pydantic",
       "path": "tools/pydantic/"
      },
      {
       "l": "In 81.5% of its projects",
       "v": "Uvicorn",
       "path": "tools/uvicorn/"
      },
      {
       "l": "In 72.8% of its projects",
       "v": "python-dotenv",
       "path": "tools/python-dotenv/"
      },
      {
       "l": "In 59.8% of its projects",
       "v": "FastAPI",
       "path": "tools/fastapi/"
      },
      {
       "l": "In 57.6% of its projects",
       "v": "Requests",
       "path": "tools/requests-py/"
      },
      {
       "l": "In 57.6% of its projects",
       "v": "Click",
       "path": "tools/click-py/"
      }
     ]
    }
   ]
  },
  {
   "id": "more",
   "nav": null,
   "spy_as": "usage",
   "h2": "More about AnyIO",
   "parts": [
    {
     "t": "more",
     "items": [
      {
       "title": "Funding",
       "path": "tools/funding/",
       "items": [
        "Tidelift: https://tidelift.com/funding/github/pypi/anyio"
       ]
      },
      {
       "title": "More in HTTP clients and networking",
       "path": "tools/http-clients/",
       "items": [
        {
         "text": "Axios",
         "path": "tools/axios/"
        },
        {
         "text": "Requests",
         "path": "tools/requests-py/"
        },
        {
         "text": "ws",
         "path": "tools/ws/"
        },
        {
         "text": "postgres",
         "path": "tools/postgres/"
        },
        {
         "text": "websockets",
         "path": "tools/websockets/"
        },
        {
         "text": "redis (Python)",
         "path": "tools/redis-pypi/"
        },
        {
         "text": "undici",
         "path": "tools/undici/"
        },
        {
         "text": "node-fetch",
         "path": "tools/node-fetch/"
        }
       ]
      }
     ]
    }
   ]
  },
  {
   "id": "alternatives",
   "nav": "Alternatives",
   "h2": "Alternatives",
   "parts": [
    {
     "t": "alts",
     "items": [
      {
       "name": "AnyIO",
       "me": true,
       "facts": [
        "MIT",
        "Gid 73",
        "261M/wk"
       ]
      },
      {
       "name": "Trio",
       "why": "Pick Trio when you are fine with one async system and want its structured concurrency directly.",
       "path": "tools/trio/",
       "facts": []
      },
      {
       "name": "Asyncer",
       "why": "Pick Asyncer when you want a thin, typed helper layer on top of AnyIO for mixing async and regular code.",
       "path": "tools/asyncer/",
       "facts": []
      },
      {
       "name": "gevent",
       "why": "Pick gevent for older code written without async and await that should still handle many connections.",
       "path": "tools/gevent/",
       "facts": []
      },
      {
       "name": "httpx",
       "why": "Modern Python HTTP client with async support, replacing the standard requests library.",
       "path": "tools/httpx/",
       "facts": [
        "BSD",
        "Gid 78",
        "198M/wk"
       ]
      },
      {
       "name": "aiohttp",
       "why": "Async HTTP client/server framework for Python with WebSocket support.",
       "path": "tools/aiohttp/",
       "facts": [
        "Apache-2.0 AND MIT",
        "Gid 81",
        "134M/wk"
       ]
      },
      {
       "name": "urllib3",
       "why": "HTTP client with thread-safe connection pooling, file uploads and advanced features.",
       "path": "tools/urllib3/",
       "facts": [
        "MIT",
        "Gid 75",
        "376M/wk"
       ]
      }
     ],
     "more": "Compare AnyIO with another tool",
     "more_path": "tools/compare/"
    }
   ]
  },
  {
   "id": "start",
   "nav": "Get started",
   "h2": "Get started",
   "parts": [
    {
     "t": "prompt",
     "text": "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."
    },
    {
     "t": "steps",
     "items": [
      {
       "text": "Install it (Python 3.10 or newer); add the trio extra only if you want Trio.",
       "code": "pip install anyio",
       "src": "https://anyio.readthedocs.io/en/stable/basics.html"
      },
      {
       "text": "Write an async main function and start it with anyio.run.",
       "code": "from anyio import run\n\nasync def main() -> None:\n    print(\"Hello, world!\")\n\nrun(main)\n",
       "src": "https://anyio.readthedocs.io/en/stable/basics.html"
      },
      {
       "text": "Start several tasks in a task group; the block ends when all of them are done.",
       "code": "async with create_task_group() as tg:\n    for num in range(5):\n        tg.start_soon(sometask, num)\n",
       "src": "https://anyio.readthedocs.io/en/stable/tasks.html"
      }
     ]
    },
    {
     "t": "h3",
     "text": "Mistakes to avoid"
    },
    {
     "t": "mistakes",
     "items": [
      {
       "dont": "try: async with create_task_group() ... except ValueError:",
       "fix": "except* ValueError:  (Python 3.11+), or exceptiongroup.catch on older Python",
       "why": "AnyIO 4 wraps even a single error in an ExceptionGroup; in our run except ValueError did not catch it."
      },
      {
       "dont": "async with move_on_after(5):",
       "fix": "with move_on_after(5):  (also fail_after)",
       "why": "Timeout scopes are plain context managers, not async ones."
      },
      {
       "dont": "to_thread.run_sync(fn, cancellable=True)",
       "fix": "to_thread.run_sync(fn, abandon_on_cancel=True)",
       "why": "The argument was renamed in AnyIO 4.1 and the old name is deprecated."
      },
      {
       "dont": "time.sleep() or requests.get() directly inside an async function",
       "fix": "await anyio.sleep(); await anyio.to_thread.run_sync(requests.get, url)",
       "why": "Blocking calls stop every other task until they return."
      },
      {
       "dont": "asyncio_mode = \"auto\" (pytest-asyncio) together with AnyIO tests",
       "fix": "Use pytestmark = pytest.mark.anyio, or remove asyncio_mode so pytest-asyncio stays in strict mode",
       "why": "The two plugins in auto mode conflict."
      }
     ]
    }
   ]
  },
  {
   "id": "faq",
   "nav": "Questions",
   "h2": "Questions",
   "parts": [
    {
     "t": "faq",
     "items": [
      {
       "q": "Do I need Trio to use it?",
       "a": "No. It runs on Python's built-in asyncio by default; Trio is an optional extra.",
       "evidence": {
        "url": "https://anyio.readthedocs.io/en/stable/basics.html",
        "quote": "This will run the program above on the default backend (asyncio)."
       }
      },
      {
       "q": "Why does except ValueError not catch the error from my task group?",
       "a": "Since AnyIO 4 the error comes inside an ExceptionGroup. Use except* ValueError on Python 3.11+, or the exceptiongroup backport.",
       "evidence": {
        "url": "https://anyio.readthedocs.io/en/stable/migration.html",
        "quote": "Task groups now wrap single exceptions in groups"
       }
      },
      {
       "q": "What is the difference between move_on_after and fail_after?",
       "a": "move_on_after quietly leaves the block when time is up; fail_after raises a TimeoutError.",
       "evidence": {
        "url": "https://anyio.readthedocs.io/en/stable/cancellation.html",
        "quote": "The difference between these two is that the former simply exits the context block prematurely on a timeout, while the other raises a TimeoutError ."
       }
      },
      {
       "q": "Can I mix it with plain asyncio code?",
       "a": "Yes. It can be adopted bit by bit and blends in with the libraries of the async system you use.",
       "evidence": {
        "url": "https://anyio.readthedocs.io/en/stable/",
        "quote": "AnyIO can also be adopted into a library or application incrementally - bit by bit, no full refactoring necessary."
       }
      }
     ]
    }
   ]
  }
 ],
 "glance": [
  [
   "Package",
   "pypi anyio"
  ],
  [
   "Category",
   "HTTP clients and networking"
  ],
  [
   "License",
   "MIT"
  ],
  [
   "Gid Score",
   "73.0"
  ],
  [
   "Rank in category",
   "#14 of 126"
  ],
  [
   "GitHub",
   "agronholm/anyio"
  ],
  [
   "Last change",
   "Nov 24, 2026"
  ]
 ],
 "good": [
  "It needs Python 3.10 or newer.",
  "In version 4, an error inside a task group always arrives wrapped in an ExceptionGroup, even when only one task failed.",
  "Cancelling a task that waits on a worker thread does not stop the thread; the thread keeps running and its result is dropped."
 ],
 "checked_line": "Read by AgentGid from 12 official pages, card checked Nov 11, 2026; numbers update daily.",
 "logo": "https://agentgid.com/media/avatars/agronholm.png"
}