56 lines
1.9 KiB
Diff
56 lines
1.9 KiB
Diff
From b03b02df6318afe26052db5b0365732152cacea2 Mon Sep 17 00:00:00 2001
|
|
From: Graham Dumpleton <Graham.Dumpleton@gmail.com>
|
|
Date: Tue, 14 May 2019 16:14:42 +1000
|
|
Subject: [PATCH] Use official APIs for accessing interpreter list.
|
|
|
|
---
|
|
src/server/wsgi_interp.c | 18 ++++++++++++------
|
|
1 file changed, 12 insertions(+), 6 deletions(-)
|
|
|
|
diff --git a/src/server/wsgi_interp.c b/src/server/wsgi_interp.c
|
|
index 4a948509..3fbca04b 100644
|
|
--- a/src/server/wsgi_interp.c
|
|
+++ b/src/server/wsgi_interp.c
|
|
@@ -338,9 +338,10 @@ static PyObject *ShutdownInterpreter_call(
|
|
|
|
PyThreadState_Swap(NULL);
|
|
|
|
- tstate = tstate->interp->tstate_head;
|
|
+ tstate = PyInterpreterState_ThreadHead(tstate->interp);
|
|
+
|
|
while (tstate) {
|
|
- tstate_next = tstate->next;
|
|
+ tstate_next = PyThreadState_Next(tstate);
|
|
if (tstate != tstate_save) {
|
|
PyThreadState_Swap(tstate);
|
|
PyThreadState_Clear(tstate);
|
|
@@ -436,9 +437,13 @@ InterpreterObject *newInterpreterObject(const char *name)
|
|
*/
|
|
|
|
if (!name) {
|
|
+#if PY_MAJOR_VERSION > 3 || (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 7)
|
|
+ interp = PyInterpreterState_Main();
|
|
+#else
|
|
interp = PyInterpreterState_Head();
|
|
- while (interp->next)
|
|
- interp = interp->next;
|
|
+ while (PyInterpreterState_Next(interp))
|
|
+ interp = PyInterpreterState_Next(interp);
|
|
+#endif
|
|
|
|
name = "";
|
|
}
|
|
@@ -1883,9 +1888,10 @@ static void Interpreter_dealloc(InterpreterObject *self)
|
|
|
|
PyThreadState_Swap(NULL);
|
|
|
|
- tstate = tstate->interp->tstate_head;
|
|
+ tstate = PyInterpreterState_ThreadHead(tstate->interp);
|
|
+
|
|
while (tstate) {
|
|
- tstate_next = tstate->next;
|
|
+ tstate_next = PyThreadState_Next(tstate);
|
|
if (tstate != tstate_save) {
|
|
PyThreadState_Swap(tstate);
|
|
PyThreadState_Clear(tstate);
|