Skip to content
Prev Previous commit
Next Next commit
Add an atexit callback for _xxinterpchannels.
  • Loading branch information
ericsnowcurrently committed Apr 5, 2023
commit 448b48a9c1f44cf0b261bf66bacce9cef2c5b9c0
10 changes: 10 additions & 0 deletions Modules/_xxinterpchannelsmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1932,6 +1932,12 @@ _global_channels(void) {
}


static void
clear_interpreter(void *data)
{
}


static PyObject *
channel_create(PyObject *self, PyObject *Py_UNUSED(ignored))
{
Expand Down Expand Up @@ -2339,6 +2345,10 @@ module_exec(PyObject *mod)
goto error;
}

// Make sure chnnels drop objects owned by this interpreter
PyInterpreterState *interp = _get_current_interp();
_Py_AtExit(interp, clear_interpreter, (void *)interp);

return 0;

error:
Expand Down