mirror of
https://github.com/python/cpython.git
synced 2025-12-31 04:23:37 +00:00
[3.14] gh-137017: Ensure Thread.is_alive() only returns False after the underlying OS thread exits (gh-137315) (gh-138916)
(cherry picked from commit aa9ceb1721)
Co-authored-by: Abdul <abdulrasheedibrahim47@gmail.com>
Co-authored-by: Sam Gross <colesbury@gmail.com>
This commit is contained in:
parent
85dabb9c15
commit
9e13cc2896
2 changed files with 6 additions and 0 deletions
|
|
@ -0,0 +1,3 @@
|
|||
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.
|
||||
|
|
@ -690,6 +690,9 @@ PyThreadHandleObject_is_done(PyObject *op, PyObject *Py_UNUSED(dummy))
|
|||
{
|
||||
PyThreadHandleObject *self = PyThreadHandleObject_CAST(op);
|
||||
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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue