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

django 里面设置了 CONN_MAX_AGE,但是使用数据库后台查看连接数和连接时间,发现还是依然有好多连接时间超过了 60s。为什么呢

  •  
  •   no13bus ·
    no13bus · 2015-01-15 20:06:30 +08:00 · 6258 次点击
    这是一个创建于 3382 天前的主题,其中的信息可能已经有所发展或是发生改变。
    这个是设置:

    DATABASES = {
    'default': {
    'ENGINE': 'django.db.backends.postgresql_psycopg2',
    'NAME': 'spider',
    'USER': 'root',
    'PASSWORD': 'root',
    'HOST': '127.0.0.1',
    'PORT': '5432',
    'CONN_MAX_AGE': 60,
    }
    }
    2 条回复    2015-01-15 20:26:33 +08:00
    est
        1
    est  
       2015-01-15 20:20:18 +08:00
    CONN_MAX_AGE 是指 idle 了60秒的连接会被reaper收走。你如果59秒一次操作59秒一次操作,就会永远长连。
    no13bus
        2
    no13bus  
    OP
       2015-01-15 20:26:33 +08:00
    @est 多谢
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2580 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 15:30 · PVG 23:30 · LAX 08:30 · JFK 11:30
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.