Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 75aa0d6

Browse files
committed
Use the new functions PyEval_AcquireThread() and
PyEval_ReleaseThread() (in ceval.c) to set/reset the current thread, and at the same time acquire/release the interpreter lock. Much saner.
1 parent 2fca21f commit 75aa0d6

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

Modules/threadmodule.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -203,12 +203,11 @@ t_bootstrap(boot_raw)
203203
void *boot_raw;
204204
{
205205
struct bootstate *boot = (struct bootstate *) boot_raw;
206-
PyThreadState *alttstate, *tstate;
206+
PyThreadState *tstate;
207207
PyObject *res;
208208

209209
tstate = PyThreadState_New(boot->interp);
210-
PyEval_RestoreThread((void *)NULL);
211-
alttstate = PyThreadState_Swap(tstate);
210+
PyEval_AcquireThread(tstate);
212211
res = PyEval_CallObjectWithKeywords(
213212
boot->func, boot->args, boot->keyw);
214213
Py_DECREF(boot->func);
@@ -225,8 +224,7 @@ t_bootstrap(boot_raw)
225224
}
226225
else
227226
Py_DECREF(res);
228-
(void) PyThreadState_Swap(alttstate);
229-
(void) PyEval_SaveThread();
227+
PyEval_ReleaseThread(tstate);
230228
PyThreadState_Delete(tstate);
231229
exit_thread();
232230
}

0 commit comments

Comments
 (0)