Windows 上的 Python - conhost.exe CPU 使用情况
我在 Windows 上运行 Python 脚本,我注意到尽管 Python 进程占用了约 8% 的 CPU,但关联的 conhost.exe
进程占用了约 14%。
为什么会这样呢?为什么这么大一部分CPU消耗是在conhost中而不是在Python进程中?
有没有办法减少这个CPU消耗呢? (当然除了优化代码)
更新1: Win7 64位,Python 2.6.6
更新2: Python程序通过SWIG Python 绑定。 C++ 包 (quickfix) 通过网络进行大量 I/O (1),它还打印到控制台 (2)。 Python 代码打印到多个文件 (3)。如果这三个人应该怀疑哪一个?
I'm running a Python script on Windows, and I've noticed that even though the Python process takes ~8% CPU, the associated conhost.exe
process takes ~14%.
Why is this so? How come such a large part of the CPU consumption is in the conhost and not in the Python process?
Is there a way to reduce this CPU consumption? (besides optimizing the code of course)
UPDATE 1: Win7 64bit, Python 2.6.6
UPDATE 2: The Python program uses a C++ package via SWIG Python bindings. The C++ package (quickfix) does I/O with the network quite a bit (1), it also prints to the console (2). The Python code prints to several files (3). Which if these three should be suspect?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
由于我们不知道您的程序在做什么,因此我们必须进行一些猜测。只要没有 I/O,我预计
conhost
会消耗 0% 的 CPU。所以我假设您正在将大量文本打印到控制台。例如,以下程序具有与您报告的相同的症状:Since we don't know what your program is doing we have to guess a little. So long as there is no I/O I'd expect
conhost
to consume 0% CPU. So I hypothesise that you are printing a lot of text to the console. For example, the following program has the same symptoms as you report: