[Python-Dev] Unloading modules (regrtest.py mystery)

M.-A. Lemburg mal@lemburg.com
Tue, 18 Dec 2001 10:22:25 +0100


Tim Peters wrote:
> 
> [MAL]
> > ...
> > Would be nice if we could come up with a reasonable way of unloading
> > modules, but I guess this requires some hard PEP work...
> 
> Yes, I believe it would.  There are different kinds of unloading too:  a
> module may well want to do different things depending on whether, e.g., it's
> really a reload, or it's because Py_Finalize was called ... hmm!  That
> reminds me:  Guido sent me this msg in March; it's still sitting in my inbox
> waiting for a rainy day:
> 
> """
> OK, so we need to define a way for modules to specify a function to be
> called at cleanup time.  I propose that we bring this out in the open,
> at least in python-dev.  Note that there are three or four potential
> cleanup times:
> 
> - when the module object is deleted from sys.modules
> 
> - when reload() is used on an extension
> 
> - when an interpreter created with PyInterpreter_New() is finalized
> 
> - when Py_Finalize() is called

I think we already have this one: I usually register a Py_AtExit (or
whatever the name is) function with Python to implement this.
 
> - when Python exits
> 
> - when the Python DLL is unloaded (Windows only)

Why Windows only ? I believe we could support this on other platforms
as well (e.g. Linux).

> """
> 
> There.  Somebody double the word count and call it a PEP <wink>.

Since Barry brought this up, I guess we already have a 
volunteer ;-)
 
> Note that this is orthogonal to regrtest -r's woes.
 
True and it won't help the suite with the encodings package 
either (how would you know what to cleanup given the fact that
the codec search functions decide how encoding names are mapped to
codecs ?).

-- 
Marc-Andre Lemburg
CEO eGenix.com Software GmbH
______________________________________________________________________
Company & Consulting:                           http://www.egenix.com/
Python Software:                   http://www.egenix.com/files/python/