Skip to content

Latest commit

 

History

History
90 lines (69 loc) · 2.15 KB

index.rst

File metadata and controls

90 lines (69 loc) · 2.15 KB

Python trio-util documentation

trio_util

nursery utilities

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

value wrappers

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

repeated events

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

generators

periodic

trio_async_generator

iterators

azip

azip_longest

exceptions

multi_error_defer_to

defer_to_cancelled

miscellaneous

TaskStats