[mod_python] Problems with mod_python on MacOS

Graham Dumpleton grahamd at dscpl.com.au
Sun Jun 26 03:38:48 EDT 2005

There is an alternate solution somewhere down below. :-)

On 26/06/2005, at 11:45 AM, Wouter van Marle wrote:

>  On Sat, 2005-06-25 at 20:27 -0400, Paul Sholtz wrote:
>>  Thanks for the advice. In fact, I already checked that Web page
>>  before I posted on this list, but .... for some reason it's still not
>>  working.
>>  I'm baffled b/c the Web page says if you get an "Internal Server
>>  Error", it probably means that Apache hasn't loaded mod_python yet,
>>  but per what I'm seeing in error_log, and per the sig I can in my
>>  apache error messages, it looks like mod_python has in fact been
>>  loaded...
>  If your script does not return any output to apache to display, then
> you also get an internal server error. So check your script!

For the "mptest" example I don't think this is the case.

If one is using mod_python.publisher and you don't write back a response
explicitly and let the function return None, then yes you will get a 500
error, but not so with mptest.

For example, for mptest.py, if you have:

   def handler(req):
     req.content_type = "text/plain"

Ie., leave off return of apache.OK, you will get an error in the browser

Mod_python error: "PythonHandler mptest"

Traceback (most recent call last):

python2.3/site-packages/mod_python/apache.py", line 310, in  
     assert (type(result) == type(int())), \

AssertionError: Handler 'mptest' returned invalid return code.


With the Python error details also appearing in the Apache error log.

If you simply don't return any content, ie.,

   def handler(req):
     return apache.OK

The browser will get a 200 and may well timeout waiting for content.

I am inclined to think that what may be happening is that the original
poster is running up against problems associated with:


This is where 500 errors are occurring in some strange situations in
the mod_python.c code file but reasons for the 500 errors aren't logged.

This exact issue was hitting someone else before with Mac OS X. It
came down to being caused by a known Mac OS X specific problem but where
rather than causing the Apache process to crash as it had for other
people, it was causing 500 errors.

End result is that original poster should try applying the patches
detailed at:


These actually address something multithreading issues, but also
include a Mac OS X specific workaround for the problem which can cause
these Apache crashes or 500 errors on that platform.


More information about the Mod_python mailing list