FastCGI/Python 线程/计时问题?

发布于 2024-12-06 03:20:40 字数 1166 浏览 1 评论 0原文

我在不支持 mod_wsgi 的共享服务器上使用 Pyramid 框架。部署项目后,我开始收到 500 个错误,但没有真正有用的错误消息:

[Thu Sep 22 21:40:52 2011] [warn] [client IP] (104)Connection reset by peer: mod_fcgid: error reading data from FastCGI server
[Thu Sep 22 21:40:52 2011] [error] [client IP] Premature end of script headers: dispatch.fcgi
[Thu Sep 22 21:40:53 2011] [warn] [client IP] (104)Connection reset by peer: mod_fcgid: error reading data from FastCGI server
[Thu Sep 22 21:40:53 2011] [error] [client IP] Premature end of script headers: dispatch.fcgi

我不太确定发生了什么,在一次(部分)意外中,我复制了应用程序的 .ini与另一个使用 sqlite 连接而不是 postgres 连接的文件。突然,我的应用程序启动并运行了。但是,我注意到响应似乎突然被切断(响应的末尾没有刷新到客户端)。

我一直在用头撞键盘试图弄清楚发生了什么,所以我希望其他人也遇到过类似的症状并找到了解决方案。

我的 fcgi 条目看起来像这样(如果它有帮助的话):

app = "/dir"
inifile = "production.ini"

import sys, os
sys.path.insert(0, app)
from paste.deploy import loadapp

wsgi_app = loadapp("config:%s/%s" % (app, inifile))

if __name__ == "__main__":
        from flup.server.fcgi import WSGIServer
        WSGIServer(wsgi_app).run()

我记得在某个地方看到一篇文章建议在单独的线程中启动 WSGI 服务器,让主线程休眠一段时间,但这似乎是一个可怕的黑客攻击大部头书。

I'm using the Pyramid framework on a shared server on which mod_wsgi isn't supported. Once I deployed the project, I started getting 500 errors with no really helpful error messages:

[Thu Sep 22 21:40:52 2011] [warn] [client IP] (104)Connection reset by peer: mod_fcgid: error reading data from FastCGI server
[Thu Sep 22 21:40:52 2011] [error] [client IP] Premature end of script headers: dispatch.fcgi
[Thu Sep 22 21:40:53 2011] [warn] [client IP] (104)Connection reset by peer: mod_fcgid: error reading data from FastCGI server
[Thu Sep 22 21:40:53 2011] [error] [client IP] Premature end of script headers: dispatch.fcgi

I wasn't overly sure what was going on, and in a (partial) accident I copied over my app's .ini file with another that used a sqlite connection rather than a postgres connection. Suddenly, my app was up and running. However, I noticed that it seemed like the response was being suddenly cut off (the end of the response wasn't being flushed to the client).

I've been banging my head against my keyboard trying to figure out what's going on, so I'm hoping that someone else has encountered similar symptoms and has figured out a solution.

My fcgi entry looks like this (in case it helps at all):

app = "/dir"
inifile = "production.ini"

import sys, os
sys.path.insert(0, app)
from paste.deploy import loadapp

wsgi_app = loadapp("config:%s/%s" % (app, inifile))

if __name__ == "__main__":
        from flup.server.fcgi import WSGIServer
        WSGIServer(wsgi_app).run()

I remember coming across a post somewhere that suggested launching the WSGI server in a separate thread, sleeping the main thread for a period of time, but that seemed like a horrible hack to me.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文