File tree 2 files changed +4
-4
lines changed
2 files changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -112,7 +112,7 @@ struct _is {
112
112
/* The thread currently executing in the __main__ module, if any. */
113
113
PyThreadState * main ;
114
114
/* Used in Modules/_threadmodule.c. */
115
- long count ;
115
+ Py_ssize_t count ;
116
116
/* Support for runtime thread stack size tuning.
117
117
A value of 0 means using the platform's default stack size
118
118
or the size specified by the THREAD_STACK_SIZE macro. */
Original file line number Diff line number Diff line change @@ -1225,7 +1225,7 @@ thread_run(void *boot_raw)
1225
1225
1226
1226
_PyThreadState_Bind (tstate );
1227
1227
PyEval_AcquireThread (tstate );
1228
- tstate -> interp -> threads .count ++ ;
1228
+ _Py_atomic_add_ssize ( & tstate -> interp -> threads .count , 1 ) ;
1229
1229
1230
1230
PyObject * res = PyObject_Call (boot -> func , boot -> args , boot -> kwargs );
1231
1231
if (res == NULL ) {
@@ -1243,7 +1243,7 @@ thread_run(void *boot_raw)
1243
1243
1244
1244
thread_bootstate_free (boot , 1 );
1245
1245
1246
- tstate -> interp -> threads .count -- ;
1246
+ _Py_atomic_add_ssize ( & tstate -> interp -> threads .count , -1 ) ;
1247
1247
PyThreadState_Clear (tstate );
1248
1248
_PyThreadState_DeleteCurrent (tstate );
1249
1249
@@ -1520,7 +1520,7 @@ static PyObject *
1520
1520
thread__count (PyObject * self , PyObject * Py_UNUSED (ignored ))
1521
1521
{
1522
1522
PyInterpreterState * interp = _PyInterpreterState_GET ();
1523
- return PyLong_FromLong (interp -> threads .count );
1523
+ return PyLong_FromLong (_Py_atomic_load_ssize ( & interp -> threads .count ) );
1524
1524
}
1525
1525
1526
1526
PyDoc_STRVAR (_count_doc ,
You can’t perform that action at this time.
0 commit comments