-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
Open
Labels
stdlibPython modules in the Lib dirPython modules in the Lib dirtype-featureA feature request or enhancementA feature request or enhancement
Description
Feature or enhancement
Currently, Thread.is_alive
will return False
shortly after the run()
function finishes, even though the underlying OS thread may still be alive.
In #110829, we made Thread.join
call the OS join API so that it waits for the OS thread to actually exit. We should apply the same behavior to Thread.is_alive()
:
- In some places, we use
Thread.is_alive
as an alternative toThread.join
. For example, intest_free_threading.test_monitoring
, the test exits once all the background threads are no longer "alive", but that may be a little too soon -- the OS threads may still be running, which can lead to false positives in the refleak tests. - The pattern for
Thread.join(timeout=...)
requires callingThread.is_alive
afterwards to differentiate timeouts vs. successful joins, butis_alive()
may return False "too soon", while the OS thread is still alive.
(Split off from #136692)
Metadata
Metadata
Assignees
Labels
stdlibPython modules in the Lib dirPython modules in the Lib dirtype-featureA feature request or enhancementA feature request or enhancement