Module runner

class sismic.runner.AsyncRunner(interpreter, interval=0.1, execute_all=False)

Bases: object

An asynchronous runner that repeatedly execute given interpreter.

The runner tries to call its execute method every interval seconds, assuming that a call to that method takes less time than interval. If not, subsequent call is queued and will occur as soon as possible with no delay. The runner stops as soon as the underlying interpreter reaches a final configuration.

The execution must be started with the start method, and can be (definitively) stopped with the stop method. An execution can be temporarily suspended using the pause and unpause methods. A call to wait blocks until the statechart reaches a final configuration.

The current state of a runner can be obtained using its running and paused properties.

While this runner can be used “as is”, it is designed to be subclassed and as such, proposes several hooks to control the execution and additional behaviours:

  • before_run: called (only once!) when the runner is started. By default, does nothing.

  • after_run: called (only once!) when the interpreter reaches a final configuration. configuration of the underlying interpreter is reached. By default, does nothing.

  • execute: called at each step of the run. By default, calls the execute_once method of the underlying interpreter and returns a list of macro steps.

  • before_execute: called right before the call to execute(). By default, does nothing.

  • after_execute: called right after the call to execute() with the returned value of execute(). By default, does nothing.

By default, this runner calls the interpreter’s execute_once method only once per cycle (meaning at least one macro step is processed during each cycle). If execute_all is set to True, then execute_once is repeatedly called until no macro step can be processed in the current cycle.

  • interpreter (Interpreter) – interpreter instance to run.

  • interval (float) – interval between two calls to execute

  • execute_all – Repeatedly call interpreter’s execute_once method at each step.

property running

Holds if execution is currently running (even if it’s paused).

property paused

Holds if execution is running but paused.


Start the execution.


Stop the execution.


Pause the execution.


Unpause the execution.


Wait for the execution to finish.


Called each time the interpreter has to be executed.

Return type:



Called before each call to execute().


Called after each call to self.execute(). Receives the return value of self.execute().


steps (List[MacroStep]) – List of macrosteps returned by self.execute()


Called before running the execution.


Called after a final configuration is reached.