[mod_python] Thread stopping and asynchronous calls

Chris Guin cguin at bbn.com
Fri Nov 16 13:44:31 EST 2007

I've been working on a custom chat server for Django (using 
mod_python), but have been hugely frustrated with the behavior of my 
"listening thread."  The thread stops at either the time.sleep() or 
select.select() call and never returns - usually when a lot of 
asynchronous requests are being answered by the server, although not 
always (even with one or two browsers left running over night, the 
thread will eventually stop).  Increasing the frequency of the async 
requests or increasing the number of browsers raises the chance of 
stoppage to near certain levels - but there's still a high random factor to it.

I have guaranteed that there is only one "listening thread" running 
at any time, and have commented out all database and network accesses 
(so my listening thread is just printing out debug statements and 
calling time.sleep() and my AJAX calls only retrieve random 
numbers).  The problem still occurs, and in the same manner.  Nor is 
it a gradual slowdown - time.sleep() takes the correct number of 
seconds to return right up until the time it fails to return at all.

When Apache starts up it says: "mod_python: Creating 8 session 
mutexes based on 256 max processes and 0 max threads."  This looks a 
little suspicious - is there a mod_python setting that I have 
incorrect?  My understanding of the workings of mod_python is fairly 
weak, so this may not even the right group to be posting to.

Thanks for any help you could give,
Chris Guin

More information about the Mod_python mailing list