标签:
def execsshVerify(hostname ,host): start = datetime.datetime.now(); t = 0; process = subprocess.Popen(‘ssh ‘+hostname+‘@‘+host +‘ -C echo ok‘, shell=True,stdout=subprocess.PIPE); while (t<4) and (process.poll() is None): t +=1; time.sleep(1); if t==3: os.kill(process.pid,signal.SIGKILL); os.waitpid(-1,os.WNOHANG); return 0; print ‘process out ‘,process.stdout.read(); return 1;超过三秒杀死该子进程并返回0未超时则返回1版权声明:本文为博主原创文章,未经博主允许不得转载。
标签:
原文地址:http://blog.csdn.net/wintersweetzeng/article/details/47319897