Skip to content

aea.runtime

This module contains the implementation of runtime for economic agent (AEA).

RuntimeStates Objects

class RuntimeStates(Enum)

Runtime states.

BaseRuntime Objects

class BaseRuntime(Runnable,  WithLogger)

Abstract runtime class to create implementations.

__init__

 | __init__(agent: AbstractAgent, loop_mode: Optional[str] = None, loop: Optional[AbstractEventLoop] = None, threaded: bool = False) -> None

Init runtime.

Arguments:

  • agent: Agent to run.
  • loop_mode: agent main loop mode.
  • loop: optional event loop. if not provided a new one will be created.

Returns:

None

loop_mode

 | @property
 | loop_mode() -> str

Get current loop mode.

setup_multiplexer

 | setup_multiplexer() -> None

Set up the multiplexer.

task_manager

 | @property
 | task_manager() -> TaskManager

Get the task manager.

loop

 | @property
 | loop() -> Optional[AbstractEventLoop]

Get event loop.

multiplexer

 | @property
 | multiplexer() -> AsyncMultiplexer

Get multiplexer.

decision_maker

 | @property
 | decision_maker() -> DecisionMaker

Return decision maker if set.

set_decision_maker

 | set_decision_maker(decision_maker_handler: DecisionMakerHandler) -> None

Set decision maker with handler provided.

is_running

 | @property
 | is_running() -> bool

Get running state of the runtime.

is_stopped

 | @property
 | is_stopped() -> bool

Get stopped state of the runtime.

set_loop

 | set_loop(loop: AbstractEventLoop) -> None

Set event loop to be used.

Arguments:

  • loop: event loop to use.

state

 | @property
 | state() -> RuntimeStates

Get runtime state.

Returns:

RuntimeStates

AsyncRuntime Objects

class AsyncRuntime(BaseRuntime)

Asynchronous runtime: uses asyncio loop for multiplexer and async agent main loop.

__init__

 | __init__(agent: AbstractAgent, loop_mode: Optional[str] = None, loop: Optional[AbstractEventLoop] = None, threaded=False) -> None

Init runtime.

Arguments:

  • agent: Agent to run.
  • loop_mode: agent main loop mode.
  • loop: optional event loop. if not provided a new one will be created.

Returns:

None

set_loop

 | set_loop(loop: AbstractEventLoop) -> None

Set event loop to be used.

Arguments:

  • loop: event loop to use.

run

 | async run() -> None

Start runtime task.

Starts multiplexer and agent loop.

stop_runtime

 | async stop_runtime() -> None

Stop runtime coroutine.

Stop main loop. Tear down the agent.. Disconnect multiplexer.

run_runtime

 | async run_runtime() -> None

Run agent and starts multiplexer.

ThreadedRuntime Objects

class ThreadedRuntime(AsyncRuntime)

Run agent and multiplexer in different threads with own asyncio loops.