子进程中的代码实际上非常简单易读.只需查看
3.3或
2.7版本(视情况而定),您就可以知道它正在做什么.
例如,调用如下所示:
def call(*popenargs, timeout=None, **kwargs):
"""Run command with arguments. Wait for command to complete or
timeout, then return the returncode attribute.
The arguments are the same as for the Popen constructor. Example:
retcode = call(["ls", "-l"])
"""
with Popen(*popenargs, **kwargs) as p:
try:
return p.wait(timeout=timeout)
except:
p.kill()
p.wait()
raise
你可以在不叫等待的情况下做同样的事情.创建一个Popen,不要等待它,这正是你想要的.