问题描述
我正在使用运行Flask-restplus 0.12.1
,SQLAlchemy==1.2.14
和Flask-SQLAlchemy==2.3.2
的API服务器的python 3.7
几个小时的空闲时间后,服务器不处理请求;当有新请求进入系统时,第一个请求将无法得到解决。但是在刷新或重新发送请求之后,应用程序将响应,因为它下次可以连接到db。
我在日志中看到以下问题。
error while fetching **********. Reason: (psycopg2.OperationalError) server closed the connection unexpectedly
(Background on this error at: http://sqlalche.me/e/e3q8)
这是初始化数据库时设置的配置参数。
# size of the database pool. Defaults to 5
flask_app.config[constants.SQLALCHEMY_POOL_SIZE] = 25
# connection timeout in secs
flask_app.config[constants.SQLALCHEMY_POOL_TIMEOUT] = 300
flask_app.config[constants.CORS_HEADERS] = 'Content-Type'
如何解决此问题?什么是正确的配置参数,用于缓解经过一段时间的闲置后导致的此问题。非常感谢,谢谢。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)