我正在使用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
roberto.. 7
很可能你是在/thesystem/code/api.py入口点打开连接.
这意味着您的文件描述符将在worker中继承,这不适用于sqlalchemy.
在你的ini配置中添加--lazy-apps(lazy-apps = true),在每个worker中加载/thesystem/code/api.py,而不是在master中加载它然后调用fork()
很可能你是在/thesystem/code/api.py入口点打开连接.
这意味着您的文件描述符将在worker中继承,这不适用于sqlalchemy.
在你的ini配置中添加--lazy-apps(lazy-apps = true),在每个worker中加载/thesystem/code/api.py,而不是在master中加载它然后调用fork()