launch_testing.tools.process module

class launch_testing.tools.process.ProcessProxy(process_action, proc_info, proc_output, *, output_filter=None)

Bases: object

A proxy to interact with launch.actions.ExecuteProcess instances.

property exit_code
property output
property running
property stderr
property stdout
property target_process_action
property terminated
wait_for_output(condition=None, timeout=None)

Wait for the target process to produce any output, either over stdout or stderr.

Parameters:
  • condition – a callable to wait on a specific output condition to be satisfied, or None (default) to wake on any output.

  • timeout – time in seconds to wait, or None (default) to block indefinitely.

Returns:

whether the condition has been satisfied or not.

wait_for_shutdown(timeout=None)

Wait for the target process to shutdown.

Parameters:

timeout – time in seconds to wait, or None to block indefinitely.

Returns:

whether the target process shut down or not.

launch_testing.tools.process.launch_process(launch_service, process_action, proc_info, proc_output, **kwargs)

Launch and interact with a process.

On context entering, start execution of a process_action using the given launch_service and yield a ProcessProxy to that process_action. On context exiting, shut the process down if it has not been terminated yet. All additional arguments are forwarded to ProcessProxy on construction.