- Support for Python 3.15
- Asynchronous implementation of the itertools module
- Added the local_port parameter to connect_tcp() to allow binding to a specific local port before connecting
- Support for custom capacity limiters in async path and file I/O functions and classes
- Added the create_task() task group method for easier asyncio migration
- Added an option for TaskGroup.start() to return a TaskHandle containing the start value in the start_value property
- Added the cancel() convenience method to TaskGroup as a shortcut for cancelling the task group's cancel scope
- TaskGroup.start_soon() now returns a TaskHandle
- Improved error message when a known backend is not installed to suggest the install command
- Improved anyio.Path to preserve subclass types by returning Self in methods that return path objects
- Changed the parameter type annotation in anyio.Path.write_bytes() to accept any ReadableBuffer, allowing bytearray and memoryview
- Changed type annotations in TaskGroup.start_soon(), TaskGroup.start(), and anyio.from_thread.run() to only accept callables returning coroutine-like objects instead of arbitrary awaitables
- Changed anyio.run to support callables returning arbitrary awaitables at runtime on all backends
- Added __slots__ to CancelScope, CapacityLimiter, Condition, Event, Lock, ResourceGuard, and Semaphore
- Fixed cancellation exception escaping a cancel scope when triggered via check_cancelled() in a worker thread
- Fixed TaskGroup raising AttributeError instead of a clear error when entered more than once
- Fixed lost type information when passing arguments to lru_cache
- Fixed test resumption after KeyboardInterrupt in async generator fixtures on the asyncio backend
- Fixed import of __main__ in to_process workers when entrypoint script doesn't end in .py
- Fixed SocketListener.from_socket() returning a TCP listener for AF_UNIX listening sockets
-
Added support for Python 3.15
-
Added an asynchronous implementation of the
itertoolsmodule (#998; PR by @11kkw) -
Added the
local_portparameter toconnect_tcp()to allow binding to a specific local port before connecting (#1067; PR by @nullwiz) -
Added support for custom capacity limiters in async path and file I/O functions and classes
-
Added the
create_task()task group method for easier asyncio migration (returns aTaskHandle) (#1098) -
Changed
TaskGroup.start_soon()to return aTaskHandle -
Added an option for
TaskGroup.start()to return aTaskHandle(which then contains the start value in thestart_valueproperty) -
Added the
cancel()convenience method toTaskGroupas a shortcut for cancelling the task group's cancel scope -
Improved the error message when a known backend is not installed to suggest the install command (#1115; PR by @EmmanuelNiyonshuti)
-
Improved
anyio.Pathto preserve subclass types by returningSelfin methods that return path objects (#1130; PR by @EmmanuelNiyonshuti) -
Changed the parameter type annotation in
anyio.Path.write_bytes()to accept anyReadableBuffer, thus allowing it to acceptbytearrayandmemoryviewto matchpathlib.Path.write_bytes()(#1135; PR by @SAY-5) -
Changed several type annotations to only accept callables returning coroutine-like objects instead of arbitrary awaitables:
TaskGroup.start_soon()TaskGroup.start()anyio.from_thread.run()
This reverts an earlier change from v3.7.0 which was made in error. (#1153)
-
Changed
anyio.runto support callables returning arbitrary awaitables at runtime on all backends. Previously, this only worked on asyncio (#1171; PR by @gschaffner) -
Changed several classes (and their subclasses) to have
__slots__(with__weakref__):anyio.CancelScopeanyio.CapacityLimiteranyio.Conditionanyio.Eventanyio.Lockanyio.ResourceGuardanyio.Semaphore
-
Fixed cancellation exception escaping a cancel scope when triggered via
check_cancelled()in a worker thread (#1113) -
Fixed
TaskGroupraisingAttributeErrorinstead of a clear error when entered more than once (#1109; PR by @bahtya) -
Fixed lost type information when passing arguments to
lru_cache(#1104; PR by @Graeme22) -
Fixed test resumption after
KeyboardInterruptin async generator fixtures on the asyncio backend (#1060; PR by @EmmanuelNiyonshuti) -
Fixed import of
__main__into_processworkers when entrypoint script doesn't end in.py, such as when usingconsole_scriptentrypoints. (#1027; PR by @tapetersen) -
Fixed
SocketListener.from_socket()returning a TCP listener forAF_UNIXlistening sockets, causingaccept()to fail withENOTSUP(#1132; PR by @kudato) -
Fixed
UDPSocket.aclose()andConnectedUDPSocket.aclose()on asyncio returning before the underlying socket FD was actually released (#1147; PR by @matias-arrelid) -
Fixed trio backend test runner hanging indefinitely instead of raising an error when dynamically accessing an async fixture via
request.getfixturevalue(#1148; PR by @EmmanuelNiyonshuti) -
Fixed cancelling tasks started through a
BlockingPortalafter the portal has been stopped (#1013; PR by @puneetdixit200) -
Fixed
backend_optionsbeing ignored when running the Trio backend viaanyio.run(); the options are now passed as keyword arguments totrio.run()again, as documented (a regression from AnyIO 3) (#1161; PR by @Zac-HD) -
Fixed asyncio
LockandSemaphoredeadlocks caused by cancelled waiters left queued during release (#1145; PR by @rasmusfaber, @x42005e1f and @agronholm)