[mod_python] threading module within mod_python

Fabiano Sidler fabianosidler at swissonline.ch
Fri Oct 7 09:28:10 EDT 2005

Graham Dumpleton wrote:
> I'm not really sure what you are trying to achieve here

The handler function should become the smallest thing in my application.
I want to build the application as a set of classes on top of everything and 
have the handler only create these classes and then pass them the control. 
Therefore I need to store the req object globally, but in a  threadsafe 
manner. Actually, I wrote a pure static class returning the thread's req
object to the caller, which I'm going to use in the lower level code of my
application otherwise written as portable as possible.

> What you are better off doing is catching any exceptions in the separate
> thread, formatting your own exception traceback and details and logging
> it directly to the Apache log using the apache.log_error() function
> provided with mod_python. This is possibly the only way to get the
> information to appear immediately.

The problem is, raised exceptions should be communicated to the client because
I intend to raise exceptions in my application too. That's why I need
exceptions to be brought to the thread in which handler() was called.

Thank you for your help!

More information about the Mod_python mailing list