unstale

pypi / anyio

anyio

What changed in anyio 4, from its official release notes, upgrade guides and advisories. Sources checked 2026-10-17.

6 breaking3 security26 new APIs and options8 performance13 behavior and defaults42 fixes and other

anyio 498 changes

Breaking changes 6

  • Now raises ValueError for an empty stem with a non-empty suffix instead of silently producing an incorrect path.

    4.15.0release notes

  • Raises ValueError when max_bytes is not a positive integer.

    4.14.2release notes

  • Support for Python 3.9 was dropped.

    4.13.0release notes

  • Functions that raised the private NoCurrentAsyncBackend exception now raise the public NoEventLoopError exception.

    4.12.1release notes

  • AnyIO adds get_available_backends() for discovering available backends.

    4.12.0release notes

  • sniffio is no longer a direct dependency of AnyIO.

    4.12.0release notes

Security 3

New APIs and options 26

  • Adds a utility function to simplify common asynchronous mapping patterns.

    4.15.0release notes

  • Adds a pytest command-line alternative to the anyio_mode ini setting.

    4.15.0release notes

  • Adds a synchronization primitive that lets tasks wait for a value or exception from another task.

    4.15.0release notes

  • Supports the standard library's newer follow_symlinks keyword on Python 3.12 and later.

    4.15.0release notes

  • Supports the standard library's newer follow_symlinks keyword on Python 3.13 and later.

    4.15.0release notes

  • Supports the standard library's newer follow_symlinks keyword on Python 3.13 and later.

    4.15.0release notes

  • Supports the standard library's newer follow_symlinks keyword on Python 3.13 and later.

    4.15.0release notes

  • Supports the standard library's newer follow_symlinks keyword on Python 3.13 and later.

    4.15.0release notes

  • Supports the standard library's newer newline keyword on Python 3.13 and later.

    4.15.0release notes

  • Adds a utility function to simplify common asynchronous completion-order patterns.

    4.15.0release notes

  • Accepts reason context that is included when TimeoutError is raised; the parameter also applies to fail_at.

    4.15.0release notes

  • Adds an absolute-deadline counterpart to fail_after.

    4.15.0release notes

  • Adds a utility function to simplify common asynchronous gathering patterns.

    4.15.0release notes

  • Adds an absolute-deadline counterpart to move_on_after.

    4.15.0release notes

  • Delegates nonblocking sends to the underlying ObjectSendStream when supported.

    4.15.0release notes

  • An asynchronous implementation of the itertools module is now available.

    4.14.0release notes

  • Async path and file I/O functions and classes now accept custom capacity limiters.

    4.14.0release notes

  • connect_tcp() can bind to a specific local port before connecting.

    4.14.0release notes

  • TaskGroup now has cancel() as a shortcut for cancelling its cancel scope.

    4.14.0release notes

  • Task groups now provide create_task(), returning a TaskHandle for easier asyncio migration.

    4.14.0release notes

  • TaskGroup.start() can return a TaskHandle containing the start value in start_value.

    4.14.0release notes

  • The lru_cache wrapper now accepts a ttl parameter.

    4.13.0release notes

  • anyio.Path.glob() and anyio.Path.rglob() now support path-like objects.

    4.12.0release notes

  • anyio.Path.glob() accepts the case_sensitive parameter.

    4.12.0release notes

  • anyio.Path.glob() accepts the recurse_symlinks parameter.

    4.12.0release notes

  • AnyIO adds an asynchronous implementation of the functools module.

    4.12.0release notes

Performance 8

  • Reduces unnecessary CPU spin when delivering cancellation on asyncio under certain nesting conditions.

    4.14.2release notes

  • CancelScope and its subclasses now define __slots__ with __weakref__.

    4.14.0release notes

  • CapacityLimiter and its subclasses now define __slots__ with __weakref__.

    4.14.0release notes

  • Condition and its subclasses now define __slots__ with __weakref__.

    4.14.0release notes

  • Event and its subclasses now define __slots__ with __weakref__.

    4.14.0release notes

  • Lock and its subclasses now define __slots__ with __weakref__.

    4.14.0release notes

  • ResourceGuard and its subclasses now define __slots__ with __weakref__.

    4.14.0release notes

  • Semaphore and its subclasses now define __slots__ with __weakref__.

    4.14.0release notes

Behavior and default changes 13

  • Default task names now match analogous start_soon and start tasks in more situations, including the module name.

    4.15.0release notes

  • The callable annotation now requires a callable returning a coroutine-like object instead of an arbitrary awaitable.

    4.14.0release notes

  • Path methods returning path objects now preserve subclass types by returning Self.

    4.14.0release notes

  • write_bytes() now accepts any ReadableBuffer, including bytearray and memoryview.

    4.14.0release notes

  • anyio.run() now supports callables returning arbitrary awaitables at runtime on all backends.

    4.14.0release notes

  • Errors for unavailable known backends now suggest the install command.

    4.14.0release notes

  • start_soon() now returns a TaskHandle.

    4.14.0release notes

  • The callable annotation now requires a callable returning a coroutine-like object instead of an arbitrary awaitable.

    4.14.0release notes

  • The callable annotation now requires a callable returning a coroutine-like object instead of an arbitrary awaitable.

    4.14.0release notes

  • File I/O stream annotations now accept IO[bytes] instead of only BinaryIO.

    4.13.0release notes

  • Public AnyIO submodules now define __all__ declarations, affecting wildcard imports and public-name introspection.

    4.12.0release notes

  • RunVar can now be used as a context manager.

    4.12.0release notes

  • A CapacityLimiter can now have a token count of zero.

    4.12.0release notes

Fixes and other changes 42

  • Direct access to anyio.* submodules now works from the main package without importing those submodules first.

    4.15.1release notes

  • Pytest auto mode detection now recognizes the mode from either the ini setting or command-line option.

    4.15.0release notes

  • Stops anyio.run from leaking or delaying collection of the event loop and root task.

    4.15.0release notes

  • Fixes a race that could raise RuntimeError when the event loop closed before a worker result was scheduled.

    4.15.0release notes

  • Prevents the asyncio backend from over-granting tokens when total_tokens increases while the limiter is over-subscribed.

    4.15.0release notes

  • Prevents asyncio task groups from leaking unawaited coroutines when a custom task constructor fails.

    4.15.0release notes

  • Fixes Python 3.14 free-threading issues affecting start_blocking_portal and to_thread.run_sync context behavior.

    4.15.0release notes

  • Removes use of the deprecated pytest alias that caused warnings on pytest 9.2 and startup crashes when warnings were errors.

    4.15.0release notes

  • Prevents readinto from reading twice before rollover, which previously overwrote buffers and advanced the file position twice.

    4.15.0release notes

  • Prevents readinto1 from reading twice before rollover, which previously overwrote buffers and advanced the file position twice.

    4.15.0release notes

  • Aligns Trio and asyncio cancellation behavior, started values, and CancelledError handling when startup is cancelled.

    4.15.0release notes

  • Fixes missing parts of the default task name for tasks started with TaskGroup.start on Trio.

    4.15.0release notes

  • Ensures cleanup runs in a shielded cancel scope when the host task is cancelled while exiting the context manager.

    4.15.0release notes

  • Prevents asyncio.InvalidStateError when closing concurrently with a just-cancelled receive or send operation.

    4.15.0release notes

  • Accepts positive infinity consistently when instantiated outside an event loop.

    4.14.2release notes

  • Raises anyio.WouldBlock consistently on the trio backend when no tokens are available.

    4.14.2release notes

  • No longer over-grants tokens during the window before a notified waiter resumes on asyncio.

    4.14.2release notes

  • CapacityLimiter.total_tokens now accepts 0 when the limiter is instantiated outside an event loop, matching documented behavior.

    4.14.1release notes

  • Teardown no longer fails on asyncio when an async test raises an outcome exception such as pytest.skip(), pytest.xfail(), or pytest.fail().

    4.14.1release notes

  • Cancelled waiters no longer cause asyncio Lock deadlocks during release.

    4.14.0release notes

  • backend_options now reach trio.run() when using the Trio backend.

    4.14.0release notes

  • Cancelled waiters no longer cause asyncio Semaphore deadlocks during release.

    4.14.0release notes

  • Tasks started through a BlockingPortal can now be cancelled after the portal has stopped.

    4.14.0release notes

  • On asyncio, aclose() now waits until the underlying socket file descriptor is released.

    4.14.0release notes

  • Passing arguments to lru_cache no longer loses type information.

    4.14.0release notes

  • AnyIO now supports running on Python 3.15.

    4.14.0release notes

  • AF_UNIX listening sockets are no longer incorrectly returned as TCP listeners.

    4.14.0release notes

  • to_process workers now import __main__ when entrypoint scripts lack a .py suffix, including console_script entrypoints.

    4.14.0release notes

  • On asyncio, aclose() now waits until the underlying socket file descriptor is released.

    4.14.0release notes

  • The pytest plugin now runs tests marked programmatically through pytest_collection_modifyitems.

    4.13.0release notes

  • Fixed compatibility with Python 3.15 pathlib changes.

    4.13.0release notes

  • Asyncio SocketStream errors now preserve the original exception as their cause.

    4.13.0release notes

  • Asyncio cancellation exceptions no longer leak from exception groups containing non-cancellation exceptions.

    4.13.0release notes

  • A notification is now passed on when cancellation occurs after the task already received it.

    4.13.0release notes

  • Still-running pooled processes are now terminated during process pool shutdown.

    4.13.0release notes

  • Using func as a parameter name no longer raises TypeError with the pytest plugin.

    4.13.0release notes

  • Fixed lru_cache so it works with instance methods.

    4.12.1release notes

  • Cancelling a Future returned by BlockingPortal.start_task_soon() now reliably cancels the async function.

    4.12.0release notes

  • The asyncio backend avoids a rare RuntimeError while shutting down the process pool.

    4.12.0release notes

  • On asyncio, Process.stdin.send() now raises ClosedResourceError and BrokenResourceError in the relevant closed or broken cases.

    4.12.0release notes

  • On asyncio, Process.stdin.send() now checkpoints before writing data.

    4.12.0release notes

  • The pytest plugin no longer breaks compatibility with pytest 6.1.2 and older.

    4.12.0release notes