iter_move_on_after()
anditer_fail_after()
are iterator wrappers that apply a timeout to a single iteration.run_and_cancelling()
is a context manager that runs a background task and cancels it on exit of the block.AsyncValue.eventual_values()
supports aheld_for
option.
move_on_when()
now returns a cancel scope other than the implementation's nursery, so that cancelled_caught is meaningful.
AsyncValue
andcompose_values()
now have type hints and generic typing.move_on_when()
is a cancel scope that exits when a given async callable returns.
_transform_
parameter ofcompose_values()
is now keyword-only.
- slight performance improvement to
AsyncValue.value
setter when there is a predicate match.
⚠ includes breaking changes!
eventual_values()
is a new iterator ofAsyncValue
which assures "eventual consistency" (i.e. the caller always receives the latest value).open_transform()
is a new context manager ofAsyncValue
enabling derived values.
compose_values()
context manager was changed from async to synchronous.compose_values()
now takes an optional transform function.RepeatedEvent
replaces bothUnqueuedRepeatedEvent
andMailboxRepeatedEvent
. The new class handles both unqueued and eventual consistency cases, while supporting multiple listeners. It also offers a one-shotwait_event()
method for cases where an iterator isn't needed.
compose_values()
had a race where the composed value may be incorrect if the underlying values are mutated while entering the async context manager.
transitions()
is a new method ofAsyncValue
that allows subscription to value transitions via an iterator.
UnqueuedRepeatedEvent
supports broadcasting to multiple listenersTaskStats
now reports all scheduling rates over a given threshold, rather than the maximum observed rate.
multi_error_defer_to()
would use the wrong context when raisingRuntimeError
@trio_async_generator
is a decorator which adapts a generator containing Trio constructs for safe use. (Normally, it's not allowed to yield from a nursery or cancel scope when implementing async generators.)
TaskStats
now reports all slow task step events over a given threshold, rather than the maximum observed task step.
AsyncDictionary
has been removed. It didn't work well for the advertised use case of multiplexing a network connection, and trying to address that while keeping the regular dict interface (itself of unproven value) seemed to result in an overly complex API. See discussion.
AsyncValue.wait_value() / wait_transition()
additionally accept a plain value to match by equality, andAsyncBool
is now a subclass ofAsyncValue
.held_for
is a new option ofAsyncValue.wait_value()
, requiring a match for the specified duration.compose_values()
is a context manager that enables waiting on conditions involving multiple async valuesmulti_error_defer_to()
is a context manager that allows deferringtrio.MultiError
exceptions to a single, privileged exception.
- Support rename of
trio.hazmat
totrio.lowlevel
Initial version