t_bootstrap(void *boot_raw)
{
struct bootstate *boot = (struct bootstate *) boot_raw;
- PyThreadState *tstate;
+ PyGILState_STATE gstate;
PyObject *res;
- tstate = PyThreadState_New(boot->interp);
- PyEval_AcquireThread(tstate);
+ gstate = PyGILState_Ensure();
res = PyEval_CallObjectWithKeywords(
boot->func, boot->args, boot->keyw);
if (res == NULL) {
Py_DECREF(boot->args);
Py_XDECREF(boot->keyw);
PyMem_DEL(boot_raw);
- PyThreadState_Clear(tstate);
- PyThreadState_DeleteCurrent();
+ PyGILState_Release(gstate);
PyThread_exit_thread();
}