各位大虾好!
我有一个脚本,内容如下:
#!/usr/bin/env python
#coding=utf-8
import subprocess,time
command = "ansible all -i /etc/ansible/hosts-online-test -m shell -a 'echo $(date)>>/tmp/111.txt && sleep 10 && echo $(date)>>/tmp/111.txt'"
print ("现在执行的是:" + command)
subprocess.Popen(command, shell=True)
time.sleep(10)
print ("10秒钟结束了")
我的目的就是先执行ansible然后休息10秒钟,应该总共是耗时20秒。当我运行它的时候,却只花了10秒钟,如图:
请问是不是因为ansible默认是与其他的进程并发运行的原因?如果是的话如何取消掉?
https://docs.python.org/3/lib...