diff Modules/threadmodule.c @ 33254:b4cb49829d3e legacy-trunk

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.
author Mark Hammond <mhammond@skippinet.com.au>
date Tue, 24 Aug 2004 22:24:08 +0000
parents 97768d87394a
children c260d3b7d582 0dd146fed9dd
line wrap: on
line diff
--- a/Modules/threadmodule.c	Tue Aug 24 14:26:43 2004 +0000
+++ b/Modules/threadmodule.c	Tue Aug 24 22:24:08 2004 +0000
@@ -425,11 +425,10 @@
 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 @@
 	Py_DECREF(boot->args);
 	Py_XDECREF(boot->keyw);
 	PyMem_DEL(boot_raw);
-	PyThreadState_Clear(tstate);
-	PyThreadState_DeleteCurrent();
+	PyGILState_Release(gstate);
 	PyThread_exit_thread();
 }