aea.helpers.multiple_
executor¶
This module contains the helpers to run multiple stoppable tasks in different modes: async, threaded, multiprocess .
ExecutorExceptionPolicies Objects¶
Runner exception policy modes.
AbstractExecutorTask Objects¶
Abstract task class to create Task classes.
__
init__
¶
Init task.
future¶
Return awaitable to get result of task execution.
future¶
Set awaitable to get result of task execution.
start¶
Implement start task function here.
stop¶
Implement stop task function here.
create_
async_
task¶
Create asyncio task for task run in asyncio loop.
Arguments:
loop
: the event loop
Returns:
task to run in asyncio loop.
id¶
Return task id.
failed¶
Return was exception failed or not.
If it's running it's not failed.
Returns:
bool
AbstractMultiprocessExecutorTask Objects¶
Task for multiprocess executor.
start¶
Return function and arguments to call within subprocess.
create_
async_
task¶
Create asyncio task for task run in asyncio loop.
Raise error, cause async mode is not supported, cause this task for multiprocess executor only.
Arguments:
loop
: the event loop
Raises:
ValueError
: async task construction not possible
AbstractMultipleExecutor Objects¶
Abstract class to create multiple executors classes.
__
init__
¶
def __init__(
tasks: Sequence[AbstractExecutorTask],
task_fail_policy: ExecutorExceptionPolicies = ExecutorExceptionPolicies.
propagate
) -> None
Init executor.
Arguments:
tasks
: sequence of AbstractExecutorTask instances to run.task_fail_policy
: the exception policy of all the tasks
is_
running¶
Return running state of the executor.
start¶
Start tasks.
stop¶
Stop tasks.
num_
failed¶
Return number of failed tasks.
failed_
tasks¶
Return sequence failed tasks.
not_
failed_
tasks¶
Return sequence successful tasks.
ThreadExecutor Objects¶
Thread based executor to run multiple agents in threads.
ProcessExecutor Objects¶
Subprocess based executor to run multiple agents in threads.
AsyncExecutor Objects¶
Thread based executor to run multiple agents in threads.
AbstractMultipleRunner Objects¶
Abstract multiple runner to create classes to launch tasks with selected mode.
__
init__
¶
def __init__(
mode: str,
fail_policy: ExecutorExceptionPolicies = ExecutorExceptionPolicies.
propagate
) -> None
Init with selected executor mode.
Arguments:
mode
: one of supported executor modesfail_policy
: one of ExecutorExceptionPolicies to be used with Executor
is_
running¶
Return state of the executor.
start¶
Run agents.
Arguments:
threaded
: run in dedicated thread without blocking current thread.
stop¶
Stop agents.
Arguments:
timeout
: timeout in seconds to wait thread stopped, only if started in thread mode.
num_
failed¶
Return number of failed tasks.
failed¶
Return sequence failed tasks.
not_
failed¶
Return sequence successful tasks.
try_
join_
thread¶
Try to join thread if running in thread mode.