atexit module in embedded Python
Greg Chapman
glc at well.com
Tue Feb 11 10:48:07 EST 2003
On Mon, 10 Feb 2003 08:17:07 +0000, "Ricardo B" <etralex at ua.pt> wrote:
> anyone here has information about the behavior of the atexit module in
>embedded Python? How does it behave on PyFinalize() and
>Py_EndInterpreter()? Or where the hell can I get some information about
>this?
Expanding on Jp's reply, sys.exitfunc (which is what atexit hooks) is not called
by Py_EndInterpreter. Also, here's a comment from Py_Finalize (in pythonrun.c)
which may (or may not) add something to your understanding (besides what is in
the docs):
/* The interpreter is still entirely intact at this point, and the
* exit funcs may be relying on that. In particular, if some thread
* or exit func is still waiting to do an import, the import machinery
* expects Py_IsInitialized() to return true. So don't say the
* interpreter is uninitialized until after the exit funcs have run.
* Note that Threading.py uses an exit func to do a join on all the
* threads created thru it, so this also protects pending imports in
* the threads created via Threading.
*/
call_sys_exitfunc();
---
Greg Chapman
More information about the Python-list
mailing list