[issue25821] Documentation for threading.enumerate / threading.Thread.is_alive is contradictory.
Changes by Anthony Green : -- assignee: docs@python components: Documentation nosy: anthonygreen, docs@python, pitrou priority: normal severity: normal status: open title: Documentation for threading.enumerate / threading.Thread.is_alive is contradictory. versions: Python 2.7, Python 3.2, Python 3.3, Python 3.4, Python 3.5, Python 3.6 ___ Python tracker <http://bugs.python.org/issue25821> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue25821] Documentation for threading.enumerate / threading.Thread.is_alive is contradictory.
New submission from Anthony Green: The documentation at https://docs.python.org/3/library/threading.html#threading.Thread.is_alive relates: > The module function enumerate() returns a list of all alive threads. The documentation at https://docs.python.org/3/library/threading.html#threading.enumerate relates: > Return a list of all Thread objects currently alive. The list includes > daemonic threads, dummy thread objects created by current_thread(), and the > main thread. This is a contradiction, since if the main thread has stopped, is_alive(main_thread) will return False, but it will still be included in the list returned by threading.enumerate. Note that this is not a TOCTTOU issue. The issue is that enumerate actually includes "all alive threads, plus one [or more? I can't tell from the code] other[s]." -- ___ Python tracker <http://bugs.python.org/issue25821> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue25821] Documentation for threading.enumerate / threading.Thread.is_alive is contradictory.
Anthony Green added the comment: The following example comes from IRC user ztane: > import threading, time > > main_thread = threading.current_thread() > > def foo(): > time.sleep(10) > print(main_thread.is_alive()) > print(list(threading.enumerate())) > > t = threading.Thread(target=foo) > t.start() False [<_MainThread(MainThread, stopped 140040101766976)>, ] -- ___ Python tracker <http://bugs.python.org/issue25821> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com