[mod_python] Mod_Python 2.7.8 and threading

Russell Yanofsky rey4 at columbia.edu
Sun Jun 1 17:27:33 EST 2003

Hi, I'm trying to get write a multithreaded script to run under mod_python
and apache 1.3 on linux, but the script seems to just freeze up at the point
of thread creation leaving the http connection open but not doing anything

I isolated the problem in a little test script:

-- begin mptest.py --
from mod_python import apache

def handler(req):
  w = Worker(req)
  req.write("Starting thread...\n")
  req.write("Joining thread...\n")
  return apache.OK

import threading

class Worker(threading.Thread):
  def __init__(self, req):
    self.req = req

  def run(self):
    self.req.write("  Hello from thread!\n")
-- end mptest.py --

-- begin .htaccess --
AddHandler python-program .py
PythonHandler mptest
PythonDebug On
-- end .htaccess --

The script runs fine on a windows box running Apache 2.0.46, Mod_Python
3.0.3, and Python 2.2.2, but it freezes on my linux server running Apache
1.3.27, Mod_Python 2.7.8, and Python 2.2.2.

The place where it seems to freeze is at w.start(). If you comment that line
out, it does complete execution. Is this problem a bug in mod_python, or
have I done something wrong?

- Russ

More information about the Mod_python mailing list