adaptive.utils module#
- class adaptive.utils.SequentialExecutor[source]#
Bases:
Executor
A trivial executor that runs functions synchronously.
This executor is mainly for testing.
- map(fn, *iterable, timeout=None, chunksize=1)[source]#
Returns an iterator equivalent to map(fn, iter).
- Parameters:
fn โ A callable that will take as many arguments as there are passed iterables.
timeout โ The maximum number of seconds to wait. If None, then there is no limit on the wait time.
chunksize โ The size of the chunks the iterable will be broken into before being passed to a child process. This argument is only used by ProcessPoolExecutor; it is ignored by ThreadPoolExecutor.
- Returns:
map(func, *iterables) but the calls may be evaluated out-of-order.
- Return type:
An iterator equivalent to
- Raises:
TimeoutError โ If the entire result iterator could not be generated before the given timeout.
- shutdown(wait=True)[source]#
Clean-up the resources associated with the Executor.
It is safe to call this method several times. Otherwise, no other methods can be called after this one.
- Parameters:
wait โ If True then shutdown will not return until all running futures have finished executing and the resources used by the executor have been reclaimed.
cancel_futures โ If True then shutdown will cancel all pending futures. Futures that are completed or running will not be cancelled.
- adaptive.utils.cache_latest(f: Callable) Callable [source]#
Cache the latest return value of the function and add it as โself._cache[f.__name__]โ.