[issue32312] Create Py_AtExitRegister C API

Neil Schemenauer report at bugs.python.org
Wed Dec 13 16:54:44 EST 2017


Neil Schemenauer <nas-python at arctrix.com> added the comment:

Private is fine.  We want to get the design correct before making it part of the official API.  My thought is that providing a handy atexit hook would be a good thing in that it could be an alternative to 3rd party code using __del__ to do cleanup.

One downside of atexit is that there is still a question of ordering the calls during shutdown.  I had the idea that maybe register() should take some sort of argument to specify when the function should be called.  That seems like leading down the road of madness maybe.  It would be useful to look at what other languages do, e.g. Java.  My understanding is that new versions of Java encourage finalizers like weakref callbacks and discourage or disallow finalizers like __del__.  I.e. you are not allowed to see the state of the object being finalized and cannot resurrect it.

Regarding m_traverse, maybe the list of finalizers should be stored somewhere in the interpreter state, not in the atexit module state.  That would make more sense to me.  atexit could merely be a way to manage it rather than actually holding it.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue32312>
_______________________________________


More information about the Python-bugs-list mailing list