host.repeat

Periodic background task runner for RemoteHost.

RepeatRunner owns the repeat-task lifecycle: starting named periodic coroutines, storing their results in a bounded deque, and cancelling them cleanly.

It is decoupled from SSH/telnet — it receives a run_cmds coroutine factory so it can be tested with an AsyncMock without any real connection.

class otto.host.repeat.RepeatRunner(run_cmds)

Bases: object

Runs named periodic command tasks and stores their results.

Parameters

run_cmds:

Async callable that accepts a list[str] | str and returns a RunResult. Typically bound to Host.run.

start(name, cmds, interval, times=-1, duration=datetime.timedelta(days=999999999, seconds=86399, microseconds=999999), until=datetime.datetime(9999, 12, 31, 23, 59, 59, 999999), on_result=None, max_history=1000)

Start a named periodic task. Raises if that name is already running.

Return type:

None

async stop(name)

Cancel a specific named periodic task.

Return type:

None

async stop_all()

Cancel all running periodic tasks.

Return type:

None

get_results(name)

Return a snapshot of stored results for a named repeat task.

Return type:

list[tuple[datetime, list[CommandStatus]]]