marvis.workflow

Allow fault-injection by executing a sequence of instructions.

Classes

Workflow

A workflow is a contains a list of commands for planned execution during the simulation.

Exceptions

SimulationStoppedException


exception marvis.workflow.SimulationStoppedException(message='Simulation Stopped')[source]

Bases: Exception

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

class marvis.workflow.Workflow(task)[source]

Bases: object

A workflow is a contains a list of commands for planned execution during the simulation.

This is based on the work of Arne Boockmeyer’s dasylab-testbed.

Note

Every Workflow creates a thread.

Example

Please use it with a decorator provided by the Scenario:

@scenario.workflow
def workflow_function_name(workflow):
    do_something()
    workflow.sleep(5)
    do_another_thing()
Parameters

task (callable) – The function to be executed in the workflow.

stop_event

An event indicating when to stop the workflow thread.

current_waiting_events

These events are waiting on some condition to come true.

task

The function being executed by the workflow thread.

stop()[source]

Stop the workflow.

Warning: Do not call this manually. This is done by the Simulation.

start()[source]

Start the workflow.

Warning: Do not call this manually. This is done by the Simulation.

sleep(duration)[source]

Sleep and wait.

Parameters

duration (float) – The duration to sleep in seconds.

wait_until(expression, expected_result, global_variables, local_variables)[source]

Wait until an expression is equal to a specific value.

Like sleep() this is a blocking call.

Parameters
  • expression – The expression to evaluate. Warning: not all expressions are supported. See https://github.com/active-expressions/active-expressions-static-python for further infos.

  • expected_result – The value to compare againt.

  • global_variables – In order to work properly, you need to pass the global variable space with globals().

  • local_variables – In order to work properly, you need to pass the global variable space with locals().

wait_until_true(expression, global_variables, local_variables)[source]

Wait until an expression is equal to True.

Like sleep() this is a blocking call.

Parameters
  • expression – The expression to evaluate. Warning: not all expressions are supported. See https://github.com/active-expressions/active-expressions-static-python for further infos.

  • global_variables – In order to work properly, you need to pass the global variable space with globals().

  • local_variables – In order to work properly, you need to pass the global variable space with locals().

Inheritance Diagramm

Inheritance diagram of marvis.workflow