Skip to content

Commit 416c522

Browse files
Use _Py_AddPendingCall() for releasing shared data.
1 parent 3b0abb0 commit 416c522

File tree

1 file changed

+3
-27
lines changed

1 file changed

+3
-27
lines changed

Python/pystate.c

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1279,38 +1279,15 @@ _PyObject_GetCrossInterpreterData(PyObject *obj, _PyCrossInterpreterData *data)
12791279
return 0;
12801280
}
12811281

1282-
static void
1282+
static int
12831283
_release_xidata(void *arg)
12841284
{
12851285
_PyCrossInterpreterData *data = (_PyCrossInterpreterData *)arg;
12861286
if (data->free != NULL) {
12871287
data->free(data->data);
12881288
}
12891289
Py_XDECREF(data->obj);
1290-
}
1291-
1292-
static void
1293-
_call_in_interpreter(PyInterpreterState *interp,
1294-
void (*func)(void *), void *arg)
1295-
{
1296-
/* We would use Py_AddPendingCall() if it weren't specific to the
1297-
* main interpreter (see bpo-33608). In the meantime we take a
1298-
* naive approach.
1299-
*/
1300-
PyThreadState *save_tstate = NULL;
1301-
if (interp != _PyInterpreterState_Get()) {
1302-
// XXX Using the "head" thread isn't strictly correct.
1303-
PyThreadState *tstate = PyInterpreterState_ThreadHead(interp);
1304-
// XXX Possible GILState issues?
1305-
save_tstate = PyThreadState_Swap(tstate);
1306-
}
1307-
1308-
func(arg);
1309-
1310-
// Switch back.
1311-
if (save_tstate != NULL) {
1312-
PyThreadState_Swap(save_tstate);
1313-
}
1290+
return 0;
13141291
}
13151292

13161293
void
@@ -1332,8 +1309,7 @@ _PyCrossInterpreterData_Release(_PyCrossInterpreterData *data)
13321309
}
13331310

13341311
// "Release" the data and/or the object.
1335-
// XXX Use _Py_AddPendingCall().
1336-
_call_in_interpreter(interp, _release_xidata, data);
1312+
_Py_AddPendingCall(interp, 0, _release_xidata, data);
13371313
}
13381314

13391315
PyObject *

0 commit comments

Comments
 (0)