trio_util
The following utilities are intended to avoid nursery boilerplate in some simple cases.
wait_any
and wait_all
are used to simultaneously run async functions which either have side effects and don't return a value, or signal merely by exiting. For example, given two trio.Event
objects a
and b
, we can wait until either event is true:
await wait_any(a.wait, b.wait)
or wait until both events are true:
await wait_all(a.wait, b.wait)
wait_any
wait_all
AsyncValue
can wrap any type, offering the ability to wait for a specific value or transition. AsyncBool
is just an AsyncValue
that defaults to False
.
AsyncValue
value
wait_value
wait_transition
transitions
AsyncBool
Sometimes you want to wait on a condition involving multiple async values. This can be achieved without resorting to polling by employing the compose_values
context manager.
compose_values
trio.Event
does not offer a clear() method, so it can't be triggered multiple times. It's for your own good.
The following are event classes which can be triggered repeatedly in a relatively safe manner.
UnqueuedRepeatedEvent
MailboxRepeatedEvent
periodic
trio_async_generator
azip
azip_longest
multi_error_defer_to
defer_to_cancelled
TaskStats