标签:python
def getResult(cmd, timeout=2): #命令超时时间 deadline = time.time() + timeout r = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE) while time.time() < deadline and r.poll() is None: time.sleep(0.1) if r.poll() is None: #检查子进程 r.kill() r.wait() return ‘‘ r.wait() r = r.stdout.read().strip() return r
python subprocess,布布扣,bubuko.com
标签:python
原文地址:http://mstools.blog.51cto.com/1104047/1407883