dragon.native.process
The Dragon native process object provides process management across one or
multiple distributed systems. ProcessTemplate
can hold a blueprint for a process
that can be used to generate many similar processes.
Functions
|
Get the PythonProcess object of the current process. |
Classes
|
|
This object describes a process managed by the Dragon runtime. |
|
This class provides a template for a Dragon process. |
- class ProcessTemplate
This class provides a template for a Dragon process.
- __init__(target: str, args: Optional[tuple] = None, kwargs: Optional[dict] = None, cwd: str = '.', env: Optional[dict] = None, stdin: Optional[int] = None, stdout: Optional[int] = None, stderr: Optional[int] = None, policy: Optional[Policy] = None)
Generic Dragon process template object defining a process based on a binary executable or a Python callable.
If the target is a callable, define the Python process executing the callable. If the target is a string, assume it’s the filename of a binary to be started. If the target file is not found, the object tries to resolve the command via the PATH environment variable. If that fails, it assumes the file is in the current working directory.
This template cannot be started, but it can be used to create many similar processes like this:
- ```Python
t = ProcessTemplate(myfunc) p1 = Process.from_template(t, ident=”NewProcess1”) p2 = Process.from_template(t, ident=”NewProcess2”)
The template stores the absolute path of the target if the target is an executable. If the target is a Python function, the template stores the Python executable in its
target
attribute, the command line parameters in itsargs
attribute and the Python data in itsargdata
attribute. To obtain the original attributes in Python use- Parameters
target (str or callable) – The binary or Python callable to execute.
args (tuple, optional) – arguments to pass to the binary or callable, defaults to None
kwargs (tuple, optional) – keyword arguments to pass to the Python callable, defaults to None
cwd (str, optional) – current working directory, defaults to “.”
env (dict, optional) – environment variables to pass to the process environment, defaults to None
stdin (int, optional) – Stdin file handling. Valid values are PIPE and None.
stdout (int, optional) – Stdout file handling. Valid values are PIPE, STDOUT and None.
stderr (int, optional) – Stderr file handling. Valid values are PIPE, STDOUT and None.
policy (dragon.infrastructure.policy.Policy) – determines the placement and resources of the process
- class Process
This object describes a process managed by the Dragon runtime.
- __init__(target: str, args: Optional[tuple] = None, kwargs: Optional[dict] = None, cwd: str = '.', env: Optional[dict] = None, ident: Optional[str] = None, _pmi_enabled: bool = False, stdin: Optional[int] = None, stdout: Optional[int] = None, stderr: Optional[int] = None, policy: Optional[Policy] = None)
Generic Dragon process object executing a binary executable or a Python callable.
Processes are named and can be looked up by specifying the
ident
keyword:Process(None, ident="Apple")
If the target is a callable, start a new Python process executing the callable. The class uses cloudpickle to transfer the callable to the child process. See the cloudpickle documentation for possible limitations.
If the target is a string, assume it’s the filename of a binary to be started. If the target file is not found, the object tries to resolve the command via the PATH environment variable. If that fails, it assumes the file is in the current working directory.
The Process class should not be subclassed, because the Dragon runtime only holds on to attributes of the Process super class, breaking the name lookup.
- Parameters
target (str or callable) – The binary or Python callable to execute.
args (tuple, optional) – arguments to pass to the binary or callable, defaults to None
kwargs (tuple, optional) – keyword arguments to pass to the Python callable, defaults to None
cwd (str, optional) – current working directory, defaults to “.”
env (dict, optional) – environment variables to pass to the process environment, defaults to None
stdin (int, optional) – Stdin file handling. Valid values are PIPE and None.
stdout (int, optional) – Stdout file handling. Valid values are PIPE, STDOUT and None.
stderr (int, optional) – Stderr file handling. Valid values are PIPE, STDOUT and None.
policy (dragon.infrastructure.policy.Policy) – determines the placement and resources of the process
- classmethod from_template(template: ProcessTemplate, ident: Optional[str] = None, _pmi_enabled: bool = False) object
A classmethod that creates a new process object from a template.
- Parameters
template (ProcessTemplate) – the template to base the process on
ident (str, optional) – intended name of the process, defaults to None
- Returns
The new process object
- Return type
dragon.native.Process
- property is_alive: bool
Check if the process is still running
- Returns
True if the process is running, False otherwise
- Return type
- terminate() None
Send SIGTERM signal to the process, terminating it.
- Returns
None
- Return type
NoneType
- property node: int
Return the unique host id of the node the process is running on.
- Returns
huid of host node.
- Return type