DPY-4011: 数据库或网络关闭了连接

huangapple go评论66阅读模式
英文:

DPY-4011: the database or network closed connection

问题

I use flask 2.2.2, gunicorn 20.1.0, sqlalchemy 2.0.13 without Flask-SQLAlchemy and oracledb 1.3.1. I have two scemas and two engines each for their own schema because they need different users to access.

When I start app, and somebody makes request, sometimes I get error as on screenshot. How can I fix this problem?

DPY-4011: 数据库或网络关闭了连接

I tried to find a solution on Google, all links said that is an Oracle driver problem, but I can't understand how to fix it.

英文:

I use flask 2.2.2, gunicorn 20.1.0, sqlalchemy 2.0.13 without Flask-SQLAlchemy and oracledb 1.3.1. I have two scemas and two engines each for their own schema because they need different users to access.
When I start app, and somebody makes request, sometimes i get error as on screenshot. How can i fix this problem?
DPY-4011: 数据库或网络关闭了连接
I tried to find solution in google, all links said that is oracle driver problem, but i can`t understand how to fix it.

答案1

得分: 0

我解决了这个问题。问题在于 SQLAlchemy 不是线程/进程安全的。因此,我创建了一个应用程序工厂函数,并将 engine.dispose(close=False) 添加到这个工厂函数中。

英文:

I solved this problem. The problem is that sqlalchemy not thread/process safe. So i create app factory function and add engine.dispose(close=False) to this factory.

huangapple
  • 本文由 发表于 2023年5月23日 00:02:25
  • 转载请务必保留本文链接:https://go.coder-hub.com/76308017.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定