Using threading to run scripts autonomously

Threading allows your Python code to run autonomously in the background, without requiring an input state change to run it. Code inside a thread will run independently of all other Python code in the project – this includes code inside the same Live Python block, or inside other Live Python blocks.

Threaded Python scripts are not triggered by values received on the inputs of the Live Python device. They start running automatically, as soon as the NWare project is deployed.

Example applications for threaded scripts include:

In this section

Syntax and structure of a threaded script

Example threaded script - counter

Example threaded script - power up mute delay

See also

Controlling the execution of Python code

Using the state variable to store a value persistently

Storing and reusing values from Python code