MCPcopy
hub / github.com/apache/airflow / execute_in_subprocess

Function execute_in_subprocess

airflow/utils/process_utils.py:128–145  ·  view source on GitHub ↗

Execute a process and stream output to logger :param cmd: command and arguments to run :type cmd: List[str]

(cmd: List[str])

Source from the content-addressed store, hash-verified

126
127
128def execute_in_subprocess(cmd: List[str]):
129 """
130 Execute a process and stream output to logger
131
132 :param cmd: command and arguments to run
133 :type cmd: List[str]
134 """
135 log.info("Executing cmd: %s", " ".join([shlex.quote(c) for c in cmd]))
136 proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, bufsize=0, close_fds=True)
137 log.info("Output:")
138 if proc.stdout:
139 with proc.stdout:
140 for line in iter(proc.stdout.readline, b''):
141 log.info("%s", line.decode().rstrip())
142
143 exit_code = proc.wait()
144 if exit_code != 0:
145 raise subprocess.CalledProcessError(exit_code, cmd)
146
147
148def execute_interactive(cmd: List[str], **kwargs):

Callers 4

prepare_virtualenvFunction · 0.90
executeMethod · 0.90
execute_callableMethod · 0.90

Calls 3

decodeMethod · 0.80
waitMethod · 0.80
infoMethod · 0.45

Tested by 1