Skip to content

The execution system

AWAIT(promise)

Creates a entity to wait (non-blocking) for a promise to complete

Parameters:

Name Type Description Default
Promise

A promise

required

END()

End the current task Returns: PollResults: The poll results of the jump. used by the task.

get_shared_variable(key, default=None)

get the value of a variable at shared scope. Or returns the passed default if it doesn't exist.

Parameters:

Name Type Description Default
key str

the variable name

required
default optional

What to return if the variable doesn't exist. Defaults to None.

None

Returns:

Name Type Description
any any

The value of the variable, or default value

get_variable(key, default=None)

get the value of a variable at task scope. Or returns the passed default if it doesn't exist.

Parameters:

Name Type Description Default
key str

the variable name

required
default optional

What to return if the variable doesn't exist. Defaults to None.

None

Returns:

Name Type Description
any any

The value of the variable, or default value

jump(label)

reset the program flow to a label

Parameters:

Name Type Description Default
label str or label

The label to jump to

required

Returns:

Name Type Description
PollResults PollResults

The poll results of the jump. used by the task.

log(message, name=None, level=None)

generate a log message

Parameters:

Name Type Description Default
message str

The message to log

required
name str

Name of the logger to log to. Defaults to None.

None
level str

The logging level to use. Defaults to None.

None

logger(name=None, file=None, var=None, std_err=False)

create or retreive a looger

Parameters:

Name Type Description Default
name str

The name of the logger. Defaults to None.

None
file str

The file to log to. Defaults to None.

None
var str

The name of a string variable to log to. Defaults to None.

None

set_shared_variable(key, value)

set the value of a variable at shared scope. Or returns the passed default if it doesn't exist.

Parameters:

Name Type Description Default
key str

the variable name

required
value any

The value to set the variable to

required

set_variable(key, value)

set the value of a variable at task scope. Or returns the passed default if it doesn't exist.

Parameters:

Name Type Description Default
key str

the variable name

required
value any

The value to set the variable to

required

sub_task_all(*args, **kwargs)

Creates a task for each argument that is a label. Also supports a data named argument to pass the data to all the tasks.

Parameters:

Name Type Description Default
args 0..n labels

the labels to schedule.

()
data dict

keyword arg to pass data to the tasks.

required

Returns: Promise: A promise that is finished when all tasks are completed.

sub_task_schedule(label, data=None, var=None)

create an new task and start running at the specified label

Parameters:

Name Type Description Default
label str or label

The label to run

required
data duct

Data to initialie task variables. Defaults to None.

None
var str

Set the variable to the task created. Defaults to None.

None

Returns:

Name Type Description
MastAsyncTask MastAsyncTask

The MAST task created

task_all(*args, **kwargs)

Creates a task for each argument that is a label. Also supports a data named argument to pass the data to all the tasks.

Parameters:

Name Type Description Default
args 0..n labels

the labels to schedule.

()
data dict

keyword arg to pass data to the tasks.

required

Returns: Promise: A promise that is finished when all tasks are completed.

task_any(*args, **kwargs)

Creates a task for each argument that is a label. Also supports a data named argument to pass the data to all the tasks.

Parameters:

Name Type Description Default
args 0..n labels

the labels to schedule.

()
data dict

keyword arg to pass data to the tasks.

required

Returns: Promise: A promise that is finished when any of the tasks completes.

task_cancel(task)

ends the specified task

Parameters:

Name Type Description Default
task MastAsyncTask

The task to end

required

task_schedule(label, data=None, var=None)

create an new task and start running at the specified label

Parameters:

Name Type Description Default
label str or label

The label to run

required
data duct

Data to initialie task variables. Defaults to None.

None
var str

Set the variable to the task created. Defaults to None.

None

Returns:

Name Type Description
MastAsyncTask MastAsyncTask

The MAST task created