A comprehensive "rule of thumb" for optimized use of Python scripts within Indigo.
Embedded Python Scripts
- will be executed within the existing Indigo Server Host Python process (see below.)
- will be terminated automatically if they do not complete within 10 seconds.
- embedded scripts will be executed consecutively; the second script will not begin until the first has finished (or has been terminated.)
- generally, it is most efficient to run scripts that will complete in under 10 seconds as embedded scripts.
- all embedded scripts should include an escape; otherwise, a hung script will take 10 seconds to "complete."
- there is only one process to run all embedded scripts.
Once the embedded script process is started it is left running indefinitely (waiting for the next embedded script to be sent to it from the Indigo Server). The result is that embedded scripts can start very quickly with little overhead (assuming an embedded script isn't already running in which case they are blocked until it is completed or the 10 second timeout)
Linked Python Scripts
- each linked script will be executed in its own (separate) process.
- will not be terminated automatically.
- scripts that take more than 10 seconds to complete should always be run as linked scripts.
- linked scripts will be executed concurrently (there is an OS limitation on the number of simultaneous processes can run at any one time; it's unlikely that users will run into this limitation.)
- all linked scripts should include an escape; otherwise, a hung script may never terminate.
- combining linked scripts to reduce the number of spawned processes may not significantly affect resources used.
General Tips
- linked scripts always start up a new process, there is some additional overhead to get them started. The process must be created and establish communication with the Indigo Server. It is relatively fast, but it is not recommended to start a hundred consecutive linked scripts that all do something simple (like changing an Indigo variable value). In that case an embedded script would be much more efficient for the CPU.
- there is no need to 'import indigo' into a script as indigo is automatically imported as a part of the host process.
- it may be helpful to schedule scripts to run at "odd" times to avoid conflicts.
Please provide any suggestions for additions, clarifications, or corrections.
Dave