mirror of
https://github.com/python/cpython
synced 2024-10-07 01:14:58 +00:00
Fix for [ 1010677 ] thread Module Breaks PyGILState_Ensure(),
and a test case. When booting a new thread, use the PyGILState API to manage the GIL.
This commit is contained in:
parent
8107ca47eb
commit
eb619bb80b
|
@ -43,3 +43,7 @@ def callback():
|
|||
|
||||
if have_thread_state:
|
||||
TestThreadState()
|
||||
import threading
|
||||
t=threading.Thread(target=TestThreadState)
|
||||
t.start()
|
||||
|
||||
|
|
|
@ -425,11 +425,10 @@ static void
|
|||
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) {
|
||||
|
@ -454,8 +453,7 @@ t_bootstrap(void *boot_raw)
|
|||
Py_DECREF(boot->args);
|
||||
Py_XDECREF(boot->keyw);
|
||||
PyMem_DEL(boot_raw);
|
||||
PyThreadState_Clear(tstate);
|
||||
PyThreadState_DeleteCurrent();
|
||||
PyGILState_Release(gstate);
|
||||
PyThread_exit_thread();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue