Skip to content

Commit

Permalink
取消sqlalchemy pool_size配置以兼容sqlalchemy
Browse files Browse the repository at this point in the history
  • Loading branch information
sunlin92 committed Mar 16, 2022
1 parent 600082e commit 76ef0bb
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions app/config/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"""

import os
import multiprocessing
from datetime import timedelta


Expand Down Expand Up @@ -32,9 +31,12 @@ class BaseConfig(object):

# flask-sqlalchemy 引擎配置
SQLALCHEMY_ENGINE_OPTIONS = {
"pool_pre_ping": True, # 每次请求前 pre-ping一下数据库, 防止db gone away
"pool_size": multiprocessing.cpu_count() * 2 + 1,
"pool_recycle": 600, # 小于等于数据库连接主动回收时间
# sqlite 不支持pool_size, 其他数据库按需配置
# "pool_size": 10,
# 每次请求前 pre-ping一下数据库, 防止db gone away
"pool_pre_ping": True,
# 小于等于数据库连接主动回收时间
"pool_recycle": 600,
}

# 令牌配置
Expand Down

0 comments on commit 76ef0bb

Please sign in to comment.