Process — Child process spawning handle

class pyuv.Process(loop)
Parameters:loop (Loop) – loop object where this handle runs (accessible through Check.loop).

Process handles allow spawning child processes which can be controlled (their stdin and stdout) with Pipe handles within an event loop.

classmethod disable_stdio_inheritance()

Disables inheritance for file descriptors / handles that this process inherited from its parent. The effect is that child processes spawned by this process don’t accidentally inherit these handles.

It is recommended to call this function as early in your program as possible, before the inherited file descriptors can be closed or duplicated.

Note that this function works on a best-effort basis: there is no guarantee that libuv can discover all file descriptors that were inherited. In general it does a better job on Windows than it does on unix.

spawn(signal)
Parameters:
  • file (string) – File to be executed.
  • exit_callback (callable) – Callback to be called when the process exits.
  • args (tuple) – Arguments to be passed to the executable.
  • env (dict) – Overrides the environment for the child process. If none is specified the one from the parent is used.
  • cwd (string) – Specifies the working directory where the child process will be executed.
  • uid (int) – UID of the user to be used if flag UV_PROCESS_SETUID is used.
  • gid (int) – GID of the group to be used if flag UV_PROCESS_SETGID is used.
  • flags (int) –

    Available flags:

    • UV_PROCESS_SETUID: set child UID
    • UV_PROCESS_SETGID: set child GID
    • UV_PROCESS_WINDOWS_HIDE: hide the subprocess console window that would normally be created. This option is only meaningful on Windows systems. On unix it is silently ignored.
    • UV_PROCESS_WINDOWS_VERBATIM_ARGUMENTS: pass arguments verbatim, that is, not enclosed in double quotes (Windows)
    • UV_PROCESS_DETACHED: detach child process from parent
  • stdio (list) – Sequence containing StdIO containers which will be used to pass stdio handles to the child process. See the StdIO class documentation for for information.

Spawn the specified child process.

Exit callback signature: callback(process_handle, exit_status, term_signal).

kill(signal)
Parameters:signal (int) – Signal to be sent to the process.

Send the specified signal to the child process.

pid

Read only

PID of the spawned process.

class pyuv.StdIO([[[stream], fd], flags])
Parameters:
  • stream (object) – Stream object.
  • fd (int) – File descriptor.
  • flags (int) – Flags.

Create a new container for passing stdio to a child process. Stream can be any stream object, that is TCP, Pipe or TTY. An arbitrary file descriptor can be passed by setting the fd parameter.

The operation mode is selected by setting the flags parameter:

  • UV_IGNORE: this container should be ignored.
  • UV_CREATE_PIPE: indicates a pipe should be created. UV_READABLE_PIPE and UV_WRITABLE_PIPE determine the direction of flow, from the child process’ perspective. Both flags may be specified to create a duplex data stream.
  • UV_INHERIT_FD: inherit the given file descriptor in the child.
  • UV_INHERIT_STREAM: inherit the file descriptor of the given stream in the child.

Previous topic

Poll — Poll handle

Next topic

Async — Async handle

This Page