You are viewing an older version (9.3.0). Go to latest (9.13.0)
{ } Raw JSON

bundles / IPython 9.3.0 / IPython / utils / _process_common / process_handler

function

IPython.utils._process_common:process_handler

source: /IPython/utils/_process_common.py :44

Signature

def   process_handler ( cmd : Union[str, List[str]] callback : Callable[[subprocess.Popen], int | str | bytes] stderr = -1 )  →  int | str | bytes

Summary

Open a command in a shell subprocess and execute a callback.

Extended Summary

This function provides common scaffolding for creating subprocess.Popen() calls. It creates a Popen object and then calls the callback with it.

Parameters

cmd : str or list

A command to be executed by the system, using subprocess.Popen. If a string is passed, it will be run in the system shell. If a list is passed, it will be used directly as arguments.

callback : callable

A one-argument function that will be called with the Popen object.

stderr : file descriptor number, optional

By default this is set to subprocess.PIPE, but you can also pass the value subprocess.STDOUT to force the subprocess' stderr to go into the same file descriptor as its stdout. This is useful to read stdout and stderr combined in the order they are generated.

Returns

: The return value of the provided callback is returned.

Aliases

  • IPython.utils._process_common.process_handler