[mod_python] Force reload?

Graham Dumpleton grahamd at dscpl.com.au
Thu Feb 3 17:18:04 EST 2005

David Geller wrote ..
> The way that python handles import is problematic for persistent 
> interpreters such as implemented by mod_python. There doesn't, to me, 
> seem any foolproof, *simple* way to solve reimportation issues in all 
> circumstances, EXCEPT for what Daniel proposes, other than by restarting
> the server. It is such a pain to make some source changes, *think* you
> have reloaded affected modules, and then find out that the changes 
> haven't taken effect!

In terms of your complaint about no one responding to your previous email,
all I can say is no one pays attention to what I post either.

As mentioned in previous followup to this post, the Vampire package has
a module import and caching system which goes quite a long way further
than the standard mod_python one in trying to address these issues. For
those modules where the import system in Vampire is used, it will track
parent/child import relationships and will correctly reimportant any parent
module in a tree when any sub import further down the tree is detected.

Thus, if you have:

  A imports B
  B imports C
  C import D

If C is change and then A accessed, then A, B and C will be reimported
automatically. As D wasn't change it will not.

A lot of work has gone into ensuring this works correctly and there aren't
any issues as yet. Of course, I would love more people to try it out and make
it better if need be.

Obviously, using such a scheme means extra checking and performance
impacts, hopefully slight. The nature of how it works means also that you
can't switch it off. Turning it off is going to make things worse for you
again unless you can gaurantee that your content is static. Such is always
the case with mod_python.

If I wasn't so damn busy right now I would write some proper documentation
for it, so you'll have to put up with snipets if information as questions dictate.

> I have used this method for awhile now, and for 
> debugging/development it seems to work (although I have some unexplained
> problems as I mentioned 11/20/2004 but never got a response on). It 
> certainly is simple, and painless enough.

Looking at your original email, you possibly didn't get a response because
it was quite hard to get ones head around the issue unless you had done
something quite similar. You might have done a bit better if you had shown
simple code examples and time line of requests and output from logging
as appropriate to illustrate the problem more clearly. You also don't seem
to mention if you had set start/max child processes to 1 to ensure that the
results weren't confused by interplay of requests going to multiple processes.

More information about the Mod_python mailing list