subprocess.py中的第1117行是:
p2cread = _winapi.GetStdHandle(_winapi.STD_INPUT_HANDLE)
这让我怀疑服务流程没有与之关联的STDIN(TBC)
通过向popen提供文件或空设备作为stdin参数,可以避免这种麻烦的代码.
在Python 3.x中,您可以简单地传递stdin = subprocess.DEVNULL.例如.
subprocess.Popen( args=[self.exec_path], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, stdin=subprocess.DEVNULL)
在Python 2.x中,您需要将文件处理程序设置为null,然后将其传递给popen:
devnull = open(os.devnull, 'wb')
subprocess.Popen( args=[self.exec_path], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, stdin=devnull)