ScriptInfo¶
- class lsst.ts.scriptqueue.ScriptInfo(log, remote, index, seq_num, is_standard, path, config, descr, log_level=0, pause_checkpoint='', stop_checkpoint='', verbose=False)¶
Bases:
objectInformation about a loaded script.
- Parameters
- log
logging.Logger Logger.
- remote
salinfo.Remote Remote for the “Script” component with index=0. This will be used to send commands but not receive events, since the queue model does that.
- index
int Index of script. This must be unique among all Script SAL components that are currently running.
- seq_num
int Command sequence number; recorded in the script info.
- is_standard
bool Is this a standard (True) or external (False) script?
- path
str,bytesoros.PathLike Path to script, relative to standard or external root dir.
- config
str Configuration data as a YAML encoded string.
- descr
str A short explanation of why this script is being run.
- log_level
int(optional) Log level for the script, as a Python logging level. 0, the default, leaves the level unchanged.
- pause_checkpoint
str(optional) Checkpoint(s) at which to pause, as a regular expression. No checkpoints if blank; all checkpoints if “.*”.
- stop_checkpoint
str(optional) Checkpoint(s) at which to stop, as a regular expression. No checkpoints if blank; all checkpoints if “.*”.
- verbose
bool(optional) If True then print log messages from the script to stdout.
- log
Attributes Summary
Set, clear or get a function to call whenever the script state changes.
True if the configure command failed.
True if the configure command succeeded.
True if the script failed.
True if the script could not be loaded.
Is this script ready to be assigned a group ID?
True if the script process was started and is done.
State of the script subprocess.
Can the script be run?
True if the script was commanded to run and is not done.
Return True if the group ID is being set.
True if the script was commanded to run or terminate.
True if the script was terminated.
Methods Summary
clear_group_id(command_script)Clear the group ID.
run()Start the script running.
set_group_id(group_id)Set the group ID.
start_loading(fullpath)Start the script process and start a task that will configure the script when it is ready.
Terminate the script and wait for the process to terminate.
Attributes Documentation
- callback¶
Set, clear or get a function to call whenever the script state changes.
It receives one argument: this ScriptInfo. Set to None to clear the callback.
- configure_failed¶
True if the configure command failed.
- configured¶
True if the configure command succeeded.
- failed¶
True if the script failed.
This will be false if the script was terminated.
- load_failed¶
True if the script could not be loaded.
- needs_group_id¶
Is this script ready to be assigned a group ID?
True if the script is configured and not started, and the group ID is neither set nor being set.
- process_done¶
True if the script process was started and is done.
Notes
This will be true if the script fails or is terminated after the process has been created. This will be false if the script is terminated before the process has been created.
- process_state¶
State of the script subprocess.
One of the
ScriptProcessStateenumeration constants.
- runnable¶
Can the script be run?
For a script to be runnable it must be configured, not started, and it must have a group ID.
- running¶
True if the script was commanded to run and is not done.
- setting_group_id¶
Return True if the group ID is being set.
- started¶
True if the script was commanded to run or terminate.
- terminated¶
True if the script was terminated.
Notes
If this is true the termination may be in progress. To wait until termination is complete:
if self.terminated and not self.process_done: await self.process_task
Methods Documentation
- clear_group_id(command_script)¶
Clear the group ID.
Can be called in any state.
- Parameters
- command_script
bool If True and if the script is configured and not started, then send setGroupId command to the script.
- command_script
- run()¶
Start the script running.
- Raises
- RuntimeError
If the script cannot be run, e.g. because:
The script has not yet been configured.
runwas already called.The script process is done.
- async set_group_id(group_id)¶
Set the group ID.
Also creates
self.set_group_id_taskand sets it done on success or to an exception if the setGroupId Script command fails.- Parameters
- group_id
str New group ID; “” to clear the group ID.
- group_id
- Raises
- RuntimeError
If the script is not in state CONFIGURED.
- asyncio.TimeoutError
If the command or reply takes too long.
- async start_loading(fullpath)¶
Start the script process and start a task that will configure the script when it is ready.
- Parameters
- fullpath
str,bytesoros.PathLike Full path to the script.
- fullpath
Notes
If loading is canceled the script process is terminated. If loading fails the script is marked as terminated.
- async terminate()¶
Terminate the script and wait for the process to terminate.
If terminating the script process takes longer than _TERMINATE_TIMEOUT, log a warning and stop waiting.
- Returns
- did_terminate
bool Returns True if the script was terminated (possibly by an earlier call to terminate), False if the script process finished before being terminated.
- did_terminate
Notes
If the process has finished, do nothing. Otherwise set self._terminate to True and:
If the process is starting, wait for it to start.
If the process is running, terminate it by sending SIGTERM.
Call the callback function, if any.