C Extended module init/cleanup
Farshid Lashkari
lashkariNO at SPAMworldviz.com
Mon Jan 23 16:26:34 EST 2006
> Can C extended python modules provide any kind module destructor, so
> that whenever the module is unloaded some cleanup is run?
I've needed the same thing before but couldn't find it. AFAIK, the best
you can do is register an exit function that will be called when python
exits. Here is a sample code snippet:
//Called when python exits
void CleanupModule(void)
{
//Perform cleanup here
}
Then in your init<module> function add the following code:
//Register function to be called when python exits
Py_AtExit(CleanupModule);
-Farshid
More information about the Python-list
mailing list