s365b.core.concurrency

Run a group of coroutines that live and die together.

Functions

all_or_cancel(coros) → list[T]

Run coroutines concurrently; if one fails, cancel the rest and wait for them.

Module Contents

async s365b.core.concurrency.all_or_cancel[T](coros: collections.abc.Iterable[collections.abc.Coroutine[Any, Any, T]]) → list[T][source]

Run coroutines concurrently; if one fails, cancel the rest and wait for them.

Unlike asyncio.gather(), nothing is left running when this returns or raises, so a caller can safely close clients and release locks afterwards.

Parameters:

coros – The coroutines.

Returns:

Their results, in order.

Raises:

Exception – The first failure, unwrapped from the task group’s exception group.