我看过很多关于我话题的帖子,但实际上我找不到解决问题的方法 . 我正在尝试在后台运行子进程,而不等待子进程执行 . 被调用的子进程是一个shell脚本,它执行许多不同的操作 . 这是我的一小段代码:
print "Execute command:", full_command
subprocess.Popen(full_command, stdin=None, stdout=None, stderr=None, close_fds=True).communicate()
print "After subprocess"
我的问题是Python等到subprocess.Popen完成它的工作 . 我读过,stdin(-out,-err)=无应该解决这个问题,但事实并非如此 . 另外close_fds = True,在这里没有用 .
1 回答
来自Popen.communicate documentation(强调我的):
如果你没有't want to wait for the process to terminate, then simply don'来电话
communicate
: