@@ -98,7 +98,7 @@ class _thread.RLock "rlockobject *" "clinic_state()->rlock_type"
9898// NOT_STARTED -> STARTING -> RUNNING -> DONE
9999// | ^
100100// | |
101- // +----- FAILED -------- +
101+ // +----- FAILED -------+
102102typedef enum {
103103 THREAD_HANDLE_NOT_STARTED = 1 ,
104104 THREAD_HANDLE_STARTING = 2 ,
@@ -398,7 +398,7 @@ thread_run(void *boot_raw)
398398 PyErr_FormatUnraisable (
399399 "Exception ignored in thread started by %R" , boot -> func );
400400 }
401- // Notify that the bootstrap is done and failed (e.g. Memory error).
401+ // Notify that bootstrap is done and failed (e.g. Memory error).
402402 set_thread_handle_state (handle , THREAD_HANDLE_FAILED );
403403 _PyEvent_Notify (& handle -> thread_is_running );
404404 }
@@ -722,7 +722,8 @@ static PyObject *
722722PyThreadHandleObject_is_running (PyObject * op , PyObject * Py_UNUSED (dummy ))
723723{
724724 PyThreadHandleObject * self = PyThreadHandleObject_CAST (op );
725- if (_PyEvent_IsSet (& self -> handle -> thread_is_running )) {
725+ if (get_thread_handle_state (self -> handle ) == THREAD_HANDLE_RUNNING
726+ && _PyEvent_IsSet (& self -> handle -> thread_is_running )) {
726727 Py_RETURN_TRUE ;
727728 }
728729 else {
@@ -2944,4 +2945,4 @@ PyMODINIT_FUNC
29442945PyInit__thread (void )
29452946{
29462947 return PyModuleDef_Init (& thread_module );
2947- }
2948+ }
0 commit comments