An "exit" function for C modules?
dsh8290 at rit.edu
Tue Dec 19 04:50:50 CET 2000
On Tue, Dec 19, 2000 at 01:51:28AM +0000, Lawrence Kesteloot wrote:
> Should I use "atexit()"? I'm concerned that I don't know
> when that's called -- it could be after some cleanup has
> been done by Python that makes decref dangerous.
The functions registered with atexit() are called when the program
(main) exits. That would be when the script is done and the
interpreter shuts down (or when the interpreter dies becuase an
exception wasn't caught).
I believe the functions registered with atexit() are called in the
order they are registered. This means that *if* (I don't know) the
interpreter registers some functions before you register yours it may
not work as you want it to.
> It seems as though there should be an "exit<modulename>"
> function like the "init<modulename>" call at an appropriate
> time that allows cleanup of globals.
Sound like a good idea to me.
More information about the Python-list