gh-127791: Fix, document, and test PyUnstable_AtExit (#127793)

This commit is contained in:
Peter Bierma 2024-12-11 06:14:04 -05:00 committed by GitHub
parent 2cdeb61b57
commit d5d84c3f13
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 71 additions and 39 deletions

View file

@ -567,6 +567,15 @@ Initializing and finalizing the interpreter
customized Python that always runs in isolated mode using
:c:func:`Py_RunMain`.
.. c:function:: int PyUnstable_AtExit(PyInterpreterState *interp, void (*func)(void *), void *data)
Register an :mod:`atexit` callback for the target interpreter *interp*.
This is similar to :c:func:`Py_AtExit`, but takes an explicit interpreter and
data pointer for the callback.
The :term:`GIL` must be held for *interp*.
.. versionadded:: 3.13
Process-wide parameters
=======================

View file

@ -426,3 +426,7 @@ Process Control
function registered last is called first. Each cleanup function will be called
at most once. Since Python's internal finalization will have completed before
the cleanup function, no Python APIs should be called by *func*.
.. seealso::
:c:func:`PyUnstable_AtExit` for passing a ``void *data`` argument.