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
dddd
V2EX  ›  Python

关于 Queue.Queue(maxsize=0)

  •  
  •   dddd · 2015-03-15 16:37:45 +08:00 · 2743 次点击
    这是一个创建于 3336 天前的主题,其中的信息可能已经有所发展或是发生改变。
    官方文档里说如果 maxsize <= 0 就代表 queue size 为 infinite。

    情况是这样的:

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

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

    但在本地(都是Ubuntu 14.04),不管 maxsize 是多少,内存占用一直很稳定,这是为毛???
    第 1 条附言  ·  2015-03-16 20:40:12 +08:00
    其实就是网上烂大街的代码……

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

    以上供参考。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2233 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 06:03 · PVG 14:03 · LAX 23:03 · JFK 02:03
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.