[mod_python] import madness!

Gregory (Grisha) Trubetskoy grisha at modpython.org
Wed May 12 14:22:11 EDT 2004


I still don't get it - once a module is imported, all subsequent imports
are ignored - are you using reload to reload the module?


On Wed, 12 May 2004, The Doctor What wrote:

> * Gregory (Grisha) Trubetskoy (grisha at modpython.org) [040511 20:36]:
> >
> > On Tue, 11 May 2004, The Doctor What wrote:
> >
> > > I have found an interesting bug.  My handler has, at it's start,
> > > something like:
> > > from blah import config
> > >
> > > This is great, works fine, etc. EXCEPT when I clean up the .pyc
> > > files in the blah directory!  Then it says that it cannot import
> > > config!
> > >
> > > Looking at sys.modules, I see that sys.modules[blah.config] is set
> > > to <module 'blah' from 'path-to/blah/config.pyc'>. It is
> > > easily reproducable.  A lame work around is to make the path-to/blah
> > > directory group read-only so that .pyc files cannot be created.
> >
> > I am not sure I understand - by "clean up" you mean delete the .pyc files
> > - but at which point do you get the "cannot import config" error?
>
> Yes, that is right.  Some how mod_python has a cached version of the
> blah module, but it points to the .pyc file.  When the .pyc file is
> removed, then it raises the ImportError.
>
> Ciao!
>
> --
> Gosh that takes me back... or is it forward?  That's the trouble with time
> travel, you never can tell."
> 	 -- Doctor Who, "Androids of Tara"
>
> The Doctor What: <fill in the blank>             http://docwhat.gerf.org/
> docwhat *at* gerf *dot* org                                        KF6VNC
>


More information about the Mod_python mailing list