summaryrefslogtreecommitdiff
path: root/Modules/_threadmodule.c
diff options
context:
space:
mode:
authorEric Snow <ericsnowcurrently@gmail.com>2017-09-05 21:43:08 -0700
committerGitHub <noreply@github.com>2017-09-05 21:43:08 -0700
commit05351c1bd8b70d1878527762174cdaaba3572395 (patch)
treee97ef4ba0ae7ffe5bd2c8969199616bffbbc4d6f /Modules/_threadmodule.c
parent833860615bedfd2484ac0623d6f01ff0578ba09f (diff)
downloadcpython-git-05351c1bd8b70d1878527762174cdaaba3572395.tar.gz
Revert "bpo-30860: Consolidate stateful runtime globals." (#3379)
Windows buildbots started failing due to include-related errors.
Diffstat (limited to 'Modules/_threadmodule.c')
-rw-r--r--Modules/_threadmodule.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/Modules/_threadmodule.c b/Modules/_threadmodule.c
index 89be96c313..da750c01cd 100644
--- a/Modules/_threadmodule.c
+++ b/Modules/_threadmodule.c
@@ -14,6 +14,7 @@
#include "pythread.h"
static PyObject *ThreadError;
+static long nb_threads = 0;
static PyObject *str_dict;
_Py_IDENTIFIER(stderr);
@@ -992,7 +993,7 @@ t_bootstrap(void *boot_raw)
tstate->thread_id = PyThread_get_thread_ident();
_PyThreadState_Init(tstate);
PyEval_AcquireThread(tstate);
- tstate->interp->num_threads++;
+ nb_threads++;
res = PyObject_Call(boot->func, boot->args, boot->keyw);
if (res == NULL) {
if (PyErr_ExceptionMatches(PyExc_SystemExit))
@@ -1019,7 +1020,7 @@ t_bootstrap(void *boot_raw)
Py_DECREF(boot->args);
Py_XDECREF(boot->keyw);
PyMem_DEL(boot_raw);
- tstate->interp->num_threads--;
+ nb_threads--;
PyThreadState_Clear(tstate);
PyThreadState_DeleteCurrent();
PyThread_exit_thread();
@@ -1158,8 +1159,7 @@ A thread's identity may be reused for another thread after it exits.");
static PyObject *
thread__count(PyObject *self)
{
- PyThreadState *tstate = PyThreadState_Get();
- return PyLong_FromLong(tstate->interp->num_threads);
+ return PyLong_FromLong(nb_threads);
}
PyDoc_STRVAR(_count_doc,
@@ -1352,7 +1352,6 @@ PyInit__thread(void)
PyObject *m, *d, *v;
double time_max;
double timeout_max;
- PyThreadState *tstate = PyThreadState_Get();
/* Initialize types: */
if (PyType_Ready(&localdummytype) < 0)
@@ -1397,7 +1396,7 @@ PyInit__thread(void)
if (PyModule_AddObject(m, "_local", (PyObject *)&localtype) < 0)
return NULL;
- tstate->interp->num_threads = 0;
+ nb_threads = 0;
str_dict = PyUnicode_InternFromString("__dict__");
if (str_dict == NULL)