C API: module cleanup function

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Fri Jan 29 18:45:47 EST 2010


En Fri, 29 Jan 2010 19:50:52 -0300, Mr.M <mrm at unknown.nospam> escribió:

> I can't figure out if there is a way to run a specialized cleanup  
> function when a module needs to be "unloaded" (i.e. just before a  
> reload() or when i quit the interpreter).

I think what you want to do isn't possible with Python 2, and it's one of  
the reasons the module handling was redesigned in Python 3.x; see PEP 3121.

> I'm thinking of something like tp_dealloc.

m_free (PyModuleDef member, in Python 3) might work for this.

-- 
Gabriel Genellina




More information about the Python-list mailing list