MCPcopy
hub / github.com/QwenLM/Qwen / run_in_subprocess

Function run_in_subprocess

recipes/tests/utils.py:7–34  ·  view source on GitHub ↗
(cmd)

Source from the content-addressed store, hash-verified

5
6
7def run_in_subprocess(cmd):
8 try:
9 with subprocess.Popen(
10 cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE
11 ) as return_info:
12 while True:
13 next_line = return_info.stdout.readline()
14 return_line = next_line.decode("utf-8", "ignore").strip()
15 if return_line == "" and return_info.poll() != None:
16 break
17 if return_line != "":
18 logging.info(return_line)
19
20 err_lines = ""
21 while True:
22 next_line = return_info.stderr.readline()
23 return_line = next_line.decode("utf-8", "ignore").strip()
24 if return_line == "" and return_info.poll() != None:
25 break
26 if return_line != "":
27 logging.info(return_line)
28 err_lines += return_line + "\n"
29
30 return_code = return_info.wait()
31 if return_code:
32 raise RuntimeError(err_lines)
33 except Exception as e:
34 raise e
35
36
37def simple_openai_api(model):

Callers 3

test_finetuneFunction · 0.90
test_inference_apiFunction · 0.90

Calls

no outgoing calls

Tested by 3

test_finetuneFunction · 0.72
test_inference_apiFunction · 0.72