使用select辅助读取subprocess.Popen进程输出时发生错误:
reads, _, _ = select.select([p.stdout, p.stderr], [], [])
OSError: [WinError 10093] 应用程序没有调用 WSAStartup,或者 WSAStartup 失败。
源代码:
p = subprocess.Popen(pyinstallerPopenCommand,
stdout = subprocess.PIPE,
stderr = subprocess.PIPE,
cwd = popenCwd,
shell = True
)
reads, _, _ = select.select([p.stdout, p.stderr], [], []) # 此处报错
for r in reads:
line = r.readline()
line = line.strip()
if line:
self.returnInfo(line.decode("utf-8"))
line = r.readline()
line = line.strip()
if line:
self.returnInfo(line.decode("utf-8"))