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

关于 Queue.Queue(maxsize=0)

  •  
  •   dddd · Mar 15, 2015 · 3895 views
    This topic created in 4220 days ago, the information mentioned may be changed or developed.
    官方文档里说如果 maxsize <= 0 就代表 queue size 为 infinite。

    情况是这样的:

    用这厮弄了个简单的线程池,没设 maxsize,在 VPS 上内存就会飙升,知道吃完为止……

    我设置一个 maxsize,VPS 上立马老实了。

    但在本地(都是Ubuntu 14.04),不管 maxsize 是多少,内存占用一直很稳定,这是为毛???
    Supplement 1  ·  Mar 16, 2015
    其实就是网上烂大街的代码……

    3 replies  •  2015-03-16 09:35:42 +08:00
    leyle
        1
    leyle  
       Mar 15, 2015
    没代码 shuogegui ?
    Zuckonit
        2
    Zuckonit  
       Mar 16, 2015
    show me your code
    ryanking8215
        3
    ryanking8215  
       Mar 16, 2015
    消费者速度慢于生产者的速度,queue当然会爆。设置maxsize,生产者会block。
    至于本机不报,还是和vps的运行环境不同所致。

    以上供参考。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2470 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 14:40 · PVG 22:40 · LAX 07:40 · JFK 10:40
    ♥ Do have faith in what you're doing.