英文:
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?
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?
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论