V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
ShiehShieh
V2EX  ›  Python

运行 python 的时候为什么出现了 cpu 使用超过 100%的情况?

  •  
  •   ShiehShieh ·
    ShiehShieh · 2015-01-31 23:39:06 +08:00 · 7431 次点击
    这是一个创建于 3344 天前的主题,其中的信息可能已经有所发展或是发生改变。

    显示有四个核在跑python,python不是一般使用时无法动用多核优势的么?
    我使用了gevent,用coroutine在运行,但是coroutine按常理不是单核单线程上运行的么?
    问什么会出现cpu120%的使用率?

    6 条回复    2015-02-01 00:44:26 +08:00
    zerh925
        1
    zerh925  
       2015-01-31 23:51:16 +08:00
    multiprocessing就可以跑在多核上面。
    ShiehShieh
        2
    ShiehShieh  
    OP
       2015-01-31 23:54:07 +08:00
    我知道python可以利用多核,我的问题是,我没有使用多进程,我用的是协程,但是出现了上述情况。
    regex
        3
    regex  
       2015-01-31 23:59:08 +08:00
    有些比较imba的库 如lxml 已经去除了GIL
    binux
        4
    binux  
       2015-02-01 00:07:23 +08:00
    可能性太多,信息不足
    ShiehShieh
        5
    ShiehShieh  
    OP
       2015-02-01 00:39:15 +08:00
    使用了beautifulsoup4, request, greenlet, gevent(使用了monky patch).
    EPr2hh6LADQWqRVH
        6
    EPr2hh6LADQWqRVH  
       2015-02-01 00:44:26 +08:00
    c代码的部分在同时运行吧
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1009 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 19:54 · PVG 03:54 · LAX 12:54 · JFK 15:54
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.