500 Internal Server Error with Python FCGI

500 Internal Server Error with Python FCGI

Posted by: Automatthias
Posted on: 2006-12-24 17:41:00

Hey,

My Python FCGI site just stopped working today. While investigating, I prepare two simple "hello, world" scripts: one in Perl and one in Python. I tried running them both from a command line and from a browser. Results are:

Perl in command-line: working
Perl in browser: working
Python in command-line: working
Python in browser: 500 Internal Server Error

Then I found out that the Python script sometimes works and sometimes doesn't. I got this kind of trackbacks:

Re: 500 Internal Server Error with Python FCGI

Posted by: Automatthias
Posted on: 2006-12-25 15:09:00

I've finally got some useful error message! I had to run a perl script, call a Python script from it, capture stderr and save it to a file. Result:

Traceback (most recent call last):
File "/home/myusername/mydomain.com/python_test.fcgi", line 17, in ?
WSGIServer(test_app).run()
File "/home/myusername/fcgi.py", line 1101, in run
thread.start_new_thread(conn.run, ())
thread.error: can't start new thread

Re: 500 Internal Server Error with Python FCGI

Posted by: Automatthias
Posted on: 2006-12-25 16:44:00

I got my Django site working after switching the "threaded" mode to "prefork":

[shasta]$ cat dispatch.fcgi
#!/usr/bin/python2.4
import sys, os
sys.path = ['/home/myuser/django_src']
sys.path = ['/home/myuser/flup_src']
sys.path = ['/home/myuser/django_projects']

# Set the DJANGO_SETTINGS_MODULE environment variable.
os.environ['DJANGO_SETTINGS_MODULE'] = "myapp.settings"

from django.core.servers.fastcgi import runfastcgi
runfastcgi(method="prefork", daemonize="false")

Edited by Automatthias on 12/25/06 05:13 PM (server time).

Re: 500 Internal Server Error with Python FCGI

Posted by: pangea33
Posted on: 2006-12-26 13:00:00

Surely no one was ignoring you, and forum traffic does seem to be way down with the holiday season. Thanks for the followup on your findings, Automatthias. That sort of thing is what makes this forum such a great resource.

Re: 500 Internal Server Error with Python FCGI

Posted by: somekool
Posted on: 2007-01-08 06:27:00

Do you know if it is possible to do the same kind of switch with Ruby On Rails application? from threaded to prefork?

my numerous 500 errors are probably from the same cause "unable to start a new thread".

thanks for finding this up.


Tags: python scriptyyyinternal server errorfcgi500 internal server errorsysperlhome xxxhello worldfastcgiexceptionsdynamic serversimple helloapache error