Skip to content

State Machine Worker API

The StateMachineWorker coordinates the execution of all registered state machines. It decides whether to run a machine synchronously (in the main loop) or asynchronously (in a separate thread).

class automation.workers.state_machine.StateMachineWorker(manager)

The main worker responsible for coordinating state machine execution.

It manages two types of execution: 1. Sync: Machines executed sequentially in the main worker thread (cooperative multitasking). 2. Async: Machines executed in separate threads (preemptive multitasking).

run(self)

Starts the worker.

Iterates through registered machines and assigns them to either the sync or async scheduler based on their configuration.

stop(self)

Stops both sync and async schedulers.