mirror of
https://github.com/python/cpython.git
synced 2025-08-03 08:34:29 +00:00
gh-101659: Add _Py_AtExit() (gh-103298)
The function is like Py_AtExit() but for a single interpreter. This is a companion to the atexit module's register() function, taking a C callback instead of a Python one. We also update the _xxinterpchannels module to use _Py_AtExit(), which is the motivating case. (This is inspired by pain points felt while working on gh-101660.)
This commit is contained in:
parent
4ec8dd10bd
commit
03089fdccc
13 changed files with 268 additions and 67 deletions
|
@ -67,16 +67,7 @@ _release_xid_data(_PyCrossInterpreterData *data, int ignoreexc)
|
|||
}
|
||||
int res = _PyCrossInterpreterData_Release(data);
|
||||
if (res < 0) {
|
||||
// XXX Fix this!
|
||||
/* The owning interpreter is already destroyed.
|
||||
* Ideally, this shouldn't ever happen. (It's highly unlikely.)
|
||||
* For now we hack around that to resolve refleaks, by decref'ing
|
||||
* the released object here, even if its the wrong interpreter.
|
||||
* The owning interpreter has already been destroyed
|
||||
* so we should be okay, especially since the currently
|
||||
* shareable types are all very basic, with no GC.
|
||||
* That said, it becomes much messier once interpreters
|
||||
* no longer share a GIL, so this needs to be fixed before then. */
|
||||
/* The owning interpreter is already destroyed. */
|
||||
_PyCrossInterpreterData_Clear(NULL, data);
|
||||
if (ignoreexc) {
|
||||
// XXX Emit a warning?
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue