Skip to content

get_subprocess

faststream.cli.supervisors.utils.get_subprocess #

get_subprocess(
    target: DecoratedCallableNone, args: Any
) -> SpawnProcess

Spawn a subprocess.

PARAMETER DESCRIPTION
target

The target function to be executed in the subprocess.

TYPE: DecoratedCallableNone

args

The arguments to be passed to the target function.

TYPE: Any

RETURNS DESCRIPTION
SpawnProcess

The spawned subprocess.

RAISES DESCRIPTION
OSError

If there is an error getting the file descriptor of sys.stdin.

Note

The above docstring is autogenerated by docstring-gen library (https://docstring-gen.airt.ai)

Source code in faststream/cli/supervisors/utils.py
def get_subprocess(target: DecoratedCallableNone, args: Any) -> SpawnProcess:
    """Spawn a subprocess.

    Args:
        target: The target function to be executed in the subprocess.
        args: The arguments to be passed to the target function.

    Returns:
        The spawned subprocess.

    Raises:
        OSError: If there is an error getting the file descriptor of sys.stdin.
    !!! note

        The above docstring is autogenerated by docstring-gen library (https://docstring-gen.airt.ai)
    """
    stdin_fileno: Optional[int]
    try:
        stdin_fileno = sys.stdin.fileno()
    except OSError:
        stdin_fileno = None

    return spawn.Process(
        target=subprocess_started,
        args=args,
        kwargs={"t": target, "stdin_fileno": stdin_fileno},
    )

Last update: 2023-11-13