Documentation
Doc/library/threading.rst says about dummy thread objects:
They are never deleted, since it is impossible to detect the termination of alien threads.
Since 3.13, Lib/threading.py does detect it: _DeleteDummyThreadOnDel is stored
in a thread-local (_thread_local_info). When the alien thread finishes, the
object is collected and removes the dummy thread from threading._active.
import _thread, threading, time
done = threading.Event()
def f():
threading.current_thread() # creates a _DummyThread
done.set()
_thread.start_new_thread(f, ())
done.wait(); time.sleep(0.3)
print([t.name for t in threading.enumerate()])
| Version |
Output |
| 3.12 |
['MainThread', 'Dummy-1'] |
| 3.13 / 3.14 / 3.15 |
['MainThread'] |
Suggested fix: drop "They are never deleted…" and say that since 3.13 a dummy
thread object is removed once the alien thread finishes. Add a versionchanged:: 3.13 note.
Linked PRs
Documentation
Doc/library/threading.rstsays about dummy thread objects:Since 3.13,
Lib/threading.pydoes detect it:_DeleteDummyThreadOnDelis storedin a thread-local (
_thread_local_info). When the alien thread finishes, theobject is collected and removes the dummy thread from
threading._active.['MainThread', 'Dummy-1']['MainThread']Suggested fix: drop "They are never deleted…" and say that since 3.13 a dummy
thread object is removed once the alien thread finishes. Add a
versionchanged:: 3.13note.Linked PRs