一:循环 忙等 子进程结束
- import subprocess
- import os
- import time
- tt = '555'
- cmd = "python /home/100003/python/mypython/sub2.py "+" 333"+" 444 "+tt
- print time.time()
- sub2 = subprocess.Popen(cmd, shell=True)
- while
本文介绍了使用Python的subprocess模块监控子进程的两种方法:一种是循环忙等待直到子进程结束,另一种是利用select模块实现子进程的超时控制。示例代码展示了如何设置超时时间并处理子进程的状态变化。
一:循环 忙等 子进程结束
1万+