python子流程.Popen在类中延迟命令

2024-06-07 05:12:50 发布

您现在位置:Python中文网/ 问答频道 /正文

当我嵌入此函数时:

def RunCommand(self, command):
   try:
      p = subprocess.Popen(command)
      stdout,stderr = p.communicate()
   except OSError, e: raise RuntimeError, "Error while executing: '%s': %s" % (" ".join( cmd ),e,)

当我的代码是类中的函数时,它会延迟。在

如果我移除类,在interpeter中或者没有类控制它的情况下执行命令,它会毫不延迟地执行命令。在

这个类是因为某种原因导致它等待或挂起吗?在

我也注意到同样的事情发生在os.popen公司我测试它只是为了看看它是否是子进程模块


Tags: 函数selfdefstderrstdout执行命令commandraise