根据您想如何使用脚本,您有两种选择。如果您希望命令阻塞并且在执行过程中不执行任何操作,则可以使用
subprocess.call。
#start and block until donesubprocess.call([data["om_points"], ">", diz['d']+"/points.xml"])
如果您想在执行过程中执行操作或将内容输入
stdin,可以
communicate在
popen调用后使用。
#start and process things, then waitp = subprocess.Popen([data["om_points"], ">", diz['d']+"/points.xml"])print "Happens while running"p.communicate() #now wait plus that you can send commands to process
如文档中所述,
wait可能会死锁,因此建议进行通信。



