process Module¶
The process module wrap a process and IO redirection
-
class
gaffer.process.Process(loop, pid, name, cmd, args=None, env=None, uid=None, gid=None, cwd=None, detach=False, shell=False, redirect_output=[], redirect_input=False, custom_streams=[], custom_channels=[], on_exit_cb=None)[source]¶ Bases:
objectclass wrapping a process
Args:
- loop: main application loop (a pyuv Loop instance)
- name: name of the process
- cmd: program command, string)
- args: the arguments for the command to run. Can be a list or
a string. If args is a string, it’s splitted using
shlex.split(). Defaults to None. - env: a mapping containing the environment variables the command will run with. Optional
- uid: int or str, user id
- gid: int or st, user group id,
- cwd: working dir
- detach: the process is launched but won’t be monitored and won’t exit when the manager is stopped.
- shell: boolean, run the script in a shell. (UNIX only)
- redirect_output: list of io to redict (max 2) this is a list of custom labels to use for the redirection. Ex: [“a”, “b”] will redirect stdoutt & stderr and stdout events will be labeled “a”
- redirect_input: Boolean (False is the default). Set it if you want to be able to write to stdin.
- custom_streams: list of additional streams that should be created
and passed to process. This is a list of streams labels. They become
available through
streamsattribute. - custom_channels: list of additional channels that should be passed to process.
-
active¶
-
closed¶
-
info¶ return the process info. If the process is monitored it return the last informations stored asynchronously by the watcher
-
monitor(listener=None)[source]¶ start to monitor the process
Listener can be any callable and receive (“stat”, process_info)
-
os_pid¶ return the process pid
-
stats¶
-
status¶ return the process status
-
class
gaffer.process.ProcessConfig(name, cmd, **settings)[source]¶ Bases:
objectobject to maintain a process config
-
DEFAULT_PARAMS= {'args': [], 'custom_channels': [], 'custom_streams': [], 'cwd': None, 'env': {}, 'gid': None, 'redirect_input': False, 'redirect_output': [], 'shell': False, 'uid': None}¶
-
make_process(loop, pid, label, env=None, on_exit=None)[source]¶ create a Process object from the configuration
Args:
- loop: main pyuv loop instance that will maintain the process
- pid: process id, generally given by the manager
- label: the job label. Usually the process type. context. A context can be for example an application.
- on_exit: callback called when the process exited.
-
-
class
gaffer.process.ProcessWatcher(loop, process)[source]¶ Bases:
objectobject to retrieve process stats
-
active¶
-
-
class
gaffer.process.RedirectIO(loop, process, stdio=[])[source]¶ Bases:
object-
pipes_count= 2¶
-
stdio¶
-
-
class
gaffer.process.RedirectStdin(loop, process)[source]¶ Bases:
objectredirect stdin allows multiple sender to write to same pipe
-
class
gaffer.process.Stream(loop, process, id)[source]¶ Bases:
gaffer.process.RedirectStdincreate custom stdio