|
Fabiano Sidler
fabianosidler at swissonline.ch
Fri Oct 7 06:04:11 EDT 2005
Hi!
I wanted the main thread to be notified about raised exceptions in other
threads. Thus I wrote a threaded handler in a way similar like this:
--- snip ---
from mod_python import apache
from threading import currentThread, Thread, Lock
mainthread = currentThread()
raiselock = Lock()
raiselist = []
def Raise(exc):
raiselock.acquire()
raiseexc.append(exc)
raiselock.release()
mainthread.Raise = Raise
class ReqThread(Thread):
def __init__(self, req):
Thread.__init__(self)
self.req = req
def run(self):
# Test raise
#raise Exception('run()')
mainthread.Raise(Exception('run()'))
return
def handler(req):
exc = None
r = ReqThread(req)
r.start(); r.join()
raiselock.acquire()
if len(raiselist): exc = raiselist.pop
raiselock.release()
if exc: raise exc
return apache.OK
--- snap ---
However, this doesn't work. If I uncomment the raise in ReqThread.run,
these exceptions even don't appear in the logs until I stop the httpd, which
causes following additional errors:
[Fri Oct 07 11:12:45 2005] [warn] child process 9229 still did not exit,
sending a SIGTERM
[Fri Oct 07 11:12:45 2005] [warn] child process 9230 still did not exit,
sending a SIGTERM
Quite strange, isn't it?
I'm running Kubuntu and httpd uses mpm_prefork. Is there a chance to get my
Threads working?
Best wishes,
Fips
|