map_concurrent()

Map an async function over items with bounded concurrency.

Usage

Source

map_concurrent(
    items,
    fn,
    *,
    limit,
    on_done=None,
)

Parameters

items: Sequence[T]

The inputs to process.

fn: Callable[[T], Awaitable[R]]

Async function applied to each item.

limit: int

Maximum number of in-flight calls.

on_done: Callable[[int], None] | None = None
Progress callback invoked with 1 as each item completes.

Returns

list[R]
The results, in input order.