Utilities
ropt.components.concurrency
Concurrency primitives for workflow coordinators.
run_concurrent runs blocking
calls on dedicated threads rather than on the event loop's shared thread pool,
which is what lets many optimizations run at once without starving each other.
For the helpers meant for scripts and applications, see
ropt.utils.
ropt.components.concurrency.run_concurrent
Run blocking jobs concurrently on dedicated threads and collect results.
Each job runs on its own thread, so the number of jobs that run at once is
not capped by any shared thread pool; limit optionally bounds how many
run simultaneously. The first job to raise makes its exception propagate as
soon as it is observed (fail-fast): jobs that have not started yet are
skipped, while any already running are abandoned, since a Python thread
cannot be stopped from the outside.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
jobs
|
Sequence[Callable[[], _T]]
|
The zero-argument callables to run, one result each. |
required |
limit
|
int | None
|
The maximum number to run at once, or |
None
|
Returns:
| Type | Description |
|---|---|
list[_T]
|
The job results, in the order of |