推荐学习书目
› 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
leafonsword
V2EX  ›  Python

同时抓取 10 个网站的网页,是用 multithread 还是 multiprocess?

  •  
  •   leafonsword ·
    leafonsword · Jul 24, 2014 · 5414 views
    This topic created in 4487 days ago, the information mentioned may be changed or developed.
    循环10次太慢了,我想同时进行,我也知道multithread有GIL锁,所以multiprocess貌似是不错选择?
    我还听说过一些其他高并发项目,如:gevent、stackless、pypy,这些和官方多进程有何区别?
    11 replies  •  2014-07-25 11:25:11 +08:00
    wy315700
    wy315700
    Jul 24, 2014❤️1
    1
    multiprocess + pool 比较好

    multithread + gevent也可以
    heiher
    heiher
    Jul 24, 2014 via iPhone❤️3
    2
    线程用来使用cpu资源的,像这种基本就是I/O为主,使用异步I/O不就好了。
    binux
    binux
    Jul 24, 2014
    3
    GIL锁是锁语句执行的,IO等待又不会被锁
    bigdude
    bigdude
    Jul 24, 2014
    4
    gevent
    ffffwh
    ffffwh
    Jul 24, 2014
    5
    异步+1
    C0VN
    C0VN
    Jul 24, 2014
    6
    我之前测试的时候,threading比gevent快耶。
    pandada8
    pandada8
    Jul 24, 2014 via Android
    7
    处理速度永远大于你的抓取速度
    withrock
    withrock
    Jul 25, 2014
    8
    我之前写过抓取糗事百科的虫,我的CPU有4个核,用threading的话,CPU的使用率不会超过25%。
    Zuckonit
    Zuckonit
    Jul 25, 2014
    9
    gevent吧
    kingxsp
    kingxsp
    Jul 25, 2014
    10
    gevent 或者 asyncio
    lianghui
    lianghui
    Jul 25, 2014
    11
    prefork span with multithread
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2681 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 42ms · UTC 13:42 · PVG 21:42 · LAX 05:42 · JFK 08:42
    ♥ Do have faith in what you're doing.