pyrevs.runner.taskrunner¶
Exceptions¶
Exception class for the runner. |
Classes¶
A plugin to configure logging on each worker. |
|
An ABC for the task runners. |
|
A task runner class based on asyncIO. |
|
A task runner class based on Dask. |
Functions¶
|
Factory that instantiates a configured runner. |
Module Contents¶
- class WorkerLoggerPlugin(loglevel: str, logfile: str | None)[source]¶
Bases:
dask.distributed.WorkerPluginA plugin to configure logging on each worker.
- class BaseRunner(runner_cfg: pyrevs.runner.config.RunnerConfig, worker_fn: collections.abc.Callable, n_workers: int = 1, loglevel: str = 'INFO', logfile: str | None = None)[source]¶
An ABC for the task runners.
- class AsIORunner(runner_cfg: pyrevs.runner.config.RunnerConfig, worker_fn: collections.abc.Callable, n_workers: int = 1, loglevel: str = 'INFO', logfile: str | None = None)[source]¶
Bases:
BaseRunnerA task runner class based on asyncIO.
An runner that relies on asyncio to schedule tasks concurrently in worker processes. Tasks are added to an internal queue from which worker can take them and put the results back into result queue.
- Variables:
_queue – an asyncio.Queue() to place the tasks in
_rqueue – an asyncio.Queue() where the results are returned
_n_workers – the number of workers in the runner
_sync_worker – the synchrone worker function
_async_worker – the asynchrone worker function
_loop – the event loop associated with the workers
_executor – an executor for the worker to work in
_workers – a list of worker tasks
- async run_tasks() list[Any][source]¶
Create worker tasks and run.
Initialize the executor and setup the workers (tasks) if not already done. The join() task is created seperately and awaited with the others in order to catch any exception coming from the workers as they are generated and stop everything as soon as one task fails.
- class DaskRunner(runner_cfg: pyrevs.runner.config.RunnerConfig, worker_fn: collections.abc.Callable, n_workers: int = 1, loglevel: str = 'INFO', logfile: str | None = None)[source]¶
Bases:
BaseRunnerA task runner class based on Dask.
An runner that relies on dask to schedule a tasks concurrently in workers.
- make_runner(runner_cfg: pyrevs.runner.config.RunnerConfig, worker_fn: collections.abc.Callable, loglevel: str = 'INFO', logfile: str | None = None, max_workers: int = -1) BaseRunner[source]¶
Factory that instantiates a configured runner.
- Parameters:
runner_cfg – a config mapping for the runner
worker_fn – a worker function
loglevel – logging level
logfile – logging file
max_workers – maximum number of workers