[mod_python] Thread safety

Dan Eloff dan.eloff at gmail.com
Thu Jun 9 13:41:51 EDT 2005


Thanks for that information, I appreciate it. I'm just going to not
worry about threaded mpms right now, in my mind it creates so many
points of potential failure and added complexity that the speed
improvement does not seem like a good trade. There's enough problems
with importing alone to make me think twice. Later when the code is
mature I'll probably go through it all and make it threadsafe.

-Dan

On 6/7/05, Graham Dumpleton <grahamd at dscpl.com.au> wrote:
> 
> On 07/06/2005, at 6:42 AM, Dan Eloff wrote:
> 
> > When using a request handler, mod_python calls handler(req) for every
> > incoming request. I would say it's a safe guess that this implies that
> > handler can be called concurrently in different threads and anything
> > done in this function and any functions it calls must be thread safe.
> > I didn't find any mention of this in the docs (I didn't look too
> > hard), so I thought I'd verify with the people sure to know.
> 
> BTW, you might want to read this old posting to the mailing list.
> 
>    http://www.modpython.org/pipermail/mod_python/2004-October/016605.html
> 
> Using threading and having automatic module reloading enabled at the
> same time can be quite dangerous. Most of the problems arise because
> of how apache.import_module() is implemented so as to use standard
> Python module importing mechanisms and storage of modules in
> sys.modules.
> 
> Some of these problems are eliminated by systems such as Vampire and
> mpservlets which have their own module loading mechanism which does
> not reload on top of an existing module. Vampire goes a bit further
> than mpservlets in as much as Vampire provides a means of still
> preserving
> data across module reloads under strict user control so that thread
> locking issues can be addressed.
> 
> Note, I posted this a fair time ago and I hope it is still accurate. I
> understand things a bit better now and so possibly I may know of
> simpler ways around the problems. :-)
> 
> 
> Graham
> 
>



More information about the Mod_python mailing list