[mod_python] multithreading support

Bryan Mongeau bryan at eevolved.com
Fri Sep 20 16:58:08 EST 2002


On September 18, 2002 08:31 pm, Praveen Kumar wrote:
> I've found messages on various lists that have stated
> that it's a myth that threads don't work w/
> mod_python, it works fine on most platforms, etc. Can
> anyone comment on that ( I *really* want to use
> threads ) ? Has anyone encountered problems w/ threads
> on a RH7.2 + Apache 1.3.26 + mod_python 2.7.8 + Python
> 2.1.3 config ?

I have successfully used threads to implement a "Janitor" that periodically 
deletes expired sessions. It is (re)started when the module is imported. It 
is part of a session module that handles cookie based user session variables. 
Usage:

from mod_python import apache
from session import CookieSession

def handler(req):
	sess = CookieSession(req)
	req.content_type="text/html"
	req.send_http_header()
	try:
		sess['hits'] += 1
	except KeyError:
		sess['hits'] = 1
	req.write("Session hits: "+str(sess['hits']))
	return apache.OK

Anyone interested in such a beast can drop me a line. I have not yet tested it 
extensively but Threads and Events definitely *seem* to work.

My setup:
apache 2.0.40
mod_python 3.0 BETA ( patched )
python 2.2.1
-- 
Bryan Mongeau
eEvolved Inc. - IT Consulting & Custom Software
http://eevolved.com/
--
"The only thing that I'd rather own than Windows is English, because then I 
could charge you two hundred and forty-nine dollars for the right to speak 
it." -- Scott McNealy




More information about the Mod_python mailing list