concurrency
Thread-pool helper for I/O-bound work such as LLM API calls.
run_concurrently(items, worker, max_workers)
Yield (index, worker(item)) for each item as it finishes.
Results arrive in completion order; use the index to restore input order.
Runs sequentially in input order when max_workers <= 1. Consume the
results in the calling thread so that side effects (file writes, DataFrame
updates, logging) stay single-threaded. If a worker raises, items not yet
started are cancelled and the exception propagates to the caller.
Source code in src/ariadne/utils/concurrency.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | |