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

有没有类似 node 中 async 一样易用的多线程库?

  •  
  •   Trim21 ·
    Trim21 · Aug 17, 2016 · 2589 views
    This topic created in 3560 days ago, the information mentioned may be changed or developed.
    之前用 node 做爬虫的时候一直用的是 async 控制并发数,到 Python 下面看了看多线程,控制线程数量有些麻烦,有没有类似 async 这样封装好的只要传递一个参数 list 和函数,能根据设定的限制自动控制并发线程数的库或者包?
    7 replies    2016-08-18 11:14:05 +08:00
    bigtan
        1
    bigtan  
       Aug 17, 2016   ❤️ 1
    multiprocessing pool
    shyling
        2
    shyling  
       Aug 17, 2016   ❤️ 1
    不是有 concurrent.futures 么?
    janxin
        3
    janxin  
       Aug 17, 2016 via iPhone
    node 的 async 不是还是单线程的么?
    Trim21
        4
    Trim21  
    OP
       Aug 17, 2016 via Android
    @janxin 其实我的意思是,彻底参数列表和函数就可以并行的。
    其实现在也是在写爬虫,要并行也是因为等 IO
    eloah
        5
    eloah  
       Aug 17, 2016
    node 本身不就是单线程的吗......
    话说,python 下也有 async 这个库......
    multiprocessing 就好啦
    latyas
        6
    latyas  
       Aug 18, 2016 via iPhone
    @Trim21 multiprocessing
    爬虫可用 tornado 或者 asyncio 这是异步 io 的库 速度可以很快
    Zuckonit
        7
    Zuckonit  
       Aug 18, 2016
    多线程: from multiprocessing.dummy import Pool as ThreadPool
    有个第三方库: threadpool
    可以考虑下协程: gevent
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3078 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 40ms · UTC 12:42 · PVG 20:42 · LAX 05:42 · JFK 08:42
    ♥ Do have faith in what you're doing.