Spaces:
Sleeping
Sleeping
import subprocess | |
from hf_api import restart_space | |
try: | |
# 启动另一个程序,并通过管道捕获其输出 | |
process = subprocess.Popen(["python", "sub_app.py"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) | |
while True: | |
output = process.stdout.readline() | |
if output: | |
print(output.decode("utf-8").strip()) | |
if process.poll() is not None: | |
break | |
finally: | |
restart_space() | |