--- /dev/null
+Fix :obj:`threading.Thread.is_alive` to remain ``True`` until the underlying OS
+thread is fully cleaned up. This avoids false negatives in edge cases
+involving thread monitoring or premature :obj:`threading.Thread.is_alive` calls.
}
static int
-join_thread(ThreadHandle *handle)
+join_thread(void *arg)
{
+ ThreadHandle *handle = (ThreadHandle*)arg;
assert(get_thread_handle_state(handle) == THREAD_HANDLE_RUNNING);
PyThread_handle_t os_handle;
if (ThreadHandle_get_os_handle(handle, &os_handle)) {
}
}
- if (_PyOnceFlag_CallOnce(&self->once, (_Py_once_fn_t *)join_thread,
- self) == -1) {
+ if (_PyOnceFlag_CallOnce(&self->once, join_thread, self) == -1) {
return -1;
}
assert(get_thread_handle_state(self) == THREAD_HANDLE_DONE);
PyObject *Py_UNUSED(ignored))
{
if (_PyEvent_IsSet(&self->handle->thread_is_exiting)) {
+ if (_PyOnceFlag_CallOnce(&self->handle->once, join_thread, self->handle) == -1) {
+ return NULL;
+ }
Py_RETURN_TRUE;
}
else {