仅当使用Chainpoint cli工具命令时,Python的子模块才挂在self.stdout.read()上的PyCharm中。

问题描述 投票:0回答:1
Python的subprocess模块在调用chp(Chainpoint cli tool)命令时挂起。但是只有当我在PyCharm中这样做时。直接在终端中的Python Shell中执行相同的操作非常完美。在PyCharm中也可以使用其他过程。似乎是chp和PyCharm之间的组合导致了此失败。

这是我尝试的:

outputs_raw = subprocess.check_output(['chp', 'version'])

它最终挂在:

[stdout = self.stdout.read()中的subprocess.py

我四处寻找解决方案,但所有其他“子进程挂起pycharm”结果都无济于事。

[我也尝试使用readingproc作为替代,建议here。这给了我一个有趣的结果。它在readingproc/core.py中不断循环:

while self._proc.poll() is None: with _unblock_read(self._proc): result = self._yield_ready_read() self._check_timeouts(chunk_timeout, total_timeout) if result is not None: self._update_chunk_time() yield result

此处result始终为None,因为self._yield_ready_read()一直返回None,所以if语句永不通过。

这是_yield_ready_read函数的外观。 (在core.py中)

def _yield_ready_read(self): stdout = b'' stderr = b'' if self._poll_stdout.poll(0): stdout = self._read_while(self._proc.stdout) if self._poll_stderr.poll(0): stderr = self._read_while(self._proc.stderr) if len(stdout) > 0 or len(stderr) > 0: return ProcessData(stdout, stderr) else: return None

我正在使用python 3.7.3

PATH在工作环境中与失败环境相同。

有人可以帮我解决此问题吗?谢谢!

Python的子进程模块在调用chp(Chainpoint cli工具)命令时挂起。但是只有当我在PyCharm中这样做时。直接在终端中的Python Shell中执行相同的操作非常完美。 ...

python pycharm subprocess
1个回答
0
投票
此问题已解决:
© www.soinside.com 2019 - 2024. All rights reserved.