且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Flask_Sqlalchemy与多线程Apache.会话与数据库不同步

更新时间:2023-08-24 15:18:16

如果有人发现此线程存在相同的问题,请参考以解决问题.

For reference if anyone finds this thread with the same issue, I fixed my problem.

我的Flask App工厂功能在早期基于Flask教程而剩下的行app.app_context().push().不幸的是,从示例代码中删除了它,否则可能有人发现了它.在项目的重组过程中,这条线被排除在外,问题得以解决.不确定为什么或仅此行会导致此问题,并且仅针对部分但不是全部请求.

My Flask App factory function had the line app.app_context().push() leftover from the early days when it was based off a Flask tutorial. Unfortunately snipped out of the example code otherwise it might have been spotted by someone. During a restructuring of the project this line was left out and the problem fixed itself. Not sure why or how this line would cause this issue, and only for some but not all requests.