saltfactories.utils.processes¶
Process related utilities
- class saltfactories.utils.processes.ProcessResult(exitcode, stdout, stderr, *, cmdline=None)[source]¶
Bases:
object
This class serves the purpose of having a common result class which will hold the resulting data from a subprocess command.
- Parameters
- Return type
None
Note
Cast
ProcessResult
to a string to pretty-print it.
- class saltfactories.utils.processes.ShellResult(exitcode, stdout, stderr, *, cmdline=None, json=None)[source]¶
Bases:
saltfactories.utils.processes.ProcessResult
This class serves the purpose of having a common result class which will hold the resulting data from a subprocess command.
- Parameters
json (dict) – The dictionary returned from the process
stdout
if it could JSON decode it.- Return type
None
Please look at
ProcessResult
for the additional supported keyword arguments documentation.
- saltfactories.utils.processes.collect_child_processes(pid)[source]¶
Try to collect any started child processes of the provided pid
- Parameters
pid (int) – The PID of the process
- saltfactories.utils.processes.terminate_process_list(process_list, kill=False, slow_stop=False)[source]¶
Terminate a list of processes
- Parameters
process_list (Iterable) – An iterable of
psutil.Process
instances to terminatekill (bool) – Kill the process instead of terminating it.
slow_stop (bool) – First try to terminate each process in the list, and if termination was not successful, kill it.
- saltfactories.utils.processes.terminate_process(pid=None, process=None, children=None, kill_children=None, slow_stop=False)[source]¶
Try to terminate/kill the started process
- Parameters
pid (int) – The PID of the process
process (Process) – An instance of
psutil.Process
children (Iterable) – An iterable of
psutil.Process
instances, children to the process being terminatedkill_children (bool) – Also try to terminate/kill child processes
slow_stop (bool) – First try to terminate each process in the list, and if termination was not successful, kill it.