Dan Eloff wrote ..
> The new importer gets my vote.
> 
> I've been using it for a while now in my development servers and it
> works great. I've not discovered any bugs. I've verified it with
> PythonAutoReload and PythonDebug in any combination of On and Off. For
> a complex hierarchy of python files in with both set to off, I've
> verified it doesn't touch the filesystem. For both set to on it
> touches the filesystem around 700 times (still < 1 second), I wouldn't
> recommend that people do that on servers without lots of spare time.
> It's a real time saver for development though! I hardly ever have to
> restart apache anymore.

Hmm, 700 seems a lot. How are you determining that?

Right at the end of your response handler, can you add:

  from mod_python import importer
  apache.log_error("modules visited %d" + len(importer._get_modules_cache())

What this is doing is accessing a special per request module cache used
to avoid problems with a module being changed part way through a
request and two bits of code loading different versions. As a consequence,
seeing how many modules are held in that, will tell you how many modules
come into play with the current request.

If you want to know what these modules actually are, you can do something
like:

  for module in importer._get_modules_cache().values():
    apache.log_error("module %s" % module.__file__)

One of things I used to do when I was testing this, was to use some of the
dependency information to produce 'dot' graph definition files and view them
in GraphViz on the Mac. Quite interesting. I should resurrect the code and
post it on the mailing list so people can play with it. I should also go back
and reaudit the code again to see how many stats are being done and
whether I am doubling up.

Graham

  

Reply via email to