Sourced from anyio's releases.
4.14.2
- Changed
ByteReceiveStream.receive()implementations to raise aValueErrorwhenmax_bytesis not a positive integer (#1191)- Fixed
CapacityLimiter.total_tokensrejectingfloat("inf")when the limiter was instantiated outside of an event loop. The adapter setter checked for infinity by identity (value is math.inf), so only the exactmath.infsingleton was accepted, while every backend setter (usingmath.isinf()) accepts any positive infinity (#1189; PR by@greymoth-jp).- Fixed
to_process.run_sync()deadlocking when the worker function writes enough data tosys.stderrto fill the (undrained) pipe buffer. The worker process now redirectssys.stderrtoos.devnullas well, matching the documented behavior- Fixed
TLSStream.wrap()matching an internationalized (unicode) host name against the peer certificate using IDNA 2003 (via the standard library) instead of IDNA 2008, which could cause the host name to be matched against the wrong certificate (#1208)- Fixed
anyio.open_process()(andrun_process()) ignoring theextra_groupsargument, as it mistakenly passed the value of thegroupargument instead (#1209)- Fixed
CapacityLimiter.acquire_nowait()andCapacityLimiter.acquire_nowait_on_behalf_of()raisingtrio.WouldBlockinstead ofanyio.WouldBlockon thetriobackend when there are no tokens available (#1218)- Fixed
CapacityLimiteron the asyncio backend over-granting tokens (borrowed_tokensexceedingtotal_tokensandavailable_tokensgoing negative) when a non-blocking acquire was made in the window between a token being released and the notified waiter resuming. The freed token is now reserved for the woken waiter right away, so the non-blocking acquire correctly raisesWouldBlock(#1170; PR by@gaoflow)- Fixed unnecessary CPU spin when delivering cancellation from
CancelScopeon asyncio under certain conditions, including improper cancel scope nesting (#1111)4.14.1
- Fixed teardown of higher-scoped async fixtures failing on asyncio with
RuntimeError: Attempted to exit cancel scope in a different task than it was entered inwhen an async test raise an outcome exception (e.g.,pytest.skip(),pytest.xfail(), orpytest.fail()) (#1179; PR by@EmmanuelNiyonshuti)- Fixed
CapacityLimiter.total_tokensrejecting a value of0when the limiter was instantiated outside of an event loop, contradicting the documented behavior of allowing 0 total tokens (#1183; PR by@nyxst4ck)4.14.0
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 aTaskHandleAdded 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 scopeImproved 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.CancelScope
... (truncated)
c384f99
Bumped up the versiondbba29d
Fixed 100% CPU spin on cancel scope misuse (#1217)6bbc6c3
Fix CapacityLimiter over-granting tokens on asyncio (#1172)6f82b25
Refactored TestTLSStream.test_receive_invalid_max_bytes() to be less
flakybe24b04
Relaxed timeouts to fix test flakiness8113506
Fix test flakiness caused by slow callback duration logging1e988b6
Fixed CapacityLimiter raising trio.WouldBlock instead of
anyio.WouldBlock (#1...44713f3
Pin setup-uv to a commit sha across downstream jobs (#1213)f1b7301
Fixed stderr writes in a worker subprocess causing a deadlock (#1207)212be93
Fix flaky test_tcp_listener_same_port using a hardcoded port (#1206)