加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Python > 正文

python – SQLAlchemy的随机错误

发布时间:2020-12-20 11:32:37 所属栏目:Python 来源:网络整理
导读:我正在使用nginx,uwsgi和SQLAlchemy的设置.我最近从SQLObject切换,现在我看到SQLAlchemy出现奇怪的随机错误.例如: sqlalchemy.exc.ResourceClosedError: This result object does not return rows. It has been closed automatically. 要么: sqlalchemy.ex
我正在使用nginx,uwsgi和SQLAlchemy的设置.我最近从SQLObject切换,现在我看到SQLAlchemy出现奇怪的随机错误.例如:

sqlalchemy.exc.ResourceClosedError: This result object does not return rows. It has been closed automatically.

要么:

sqlalchemy.exc.NoSuchColumnError: "Could not locate column in row for column 'module.id'"

这是SQLAlchemy中的一种我不知道的行为吗?它可以与uwsgi中的多个进程/线程相关吗?

我的uwsgi配置文件如下所示:

[uwsgi]
plugins=python
socket = 127.0.0.1:9002
wsgi-file = /thesystem/code/api.py
master = True
processes  = 4
threads = 2
daemonize = /thesystem/logs/uwsgi.log
pidfile = /thesystem/uwsgi.pid

解决方法

很可能你是在/thesystem/code/api.py入口点打开连接.

这意味着您的文件描述符将在worker中继承,这不适用于sqlalchemy.

在你的ini配置中添加–lazy-apps(lazy-apps = true),在每个worker中加载/thesystem/code/api.py,而不是在master中加载它然后调用fork()

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读