I tried asking this on SO (no response), so I'm hoping it might be a little more familiar to someone here...
(I would have also tagged this with
flup, but apparently they're new tags and I don't have the rep to do so :P)
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.