-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
bpo-25821: Fix inaccuracy in threading.enumerate/is_alive documentation #23192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The list returned by enumerate contains all alive threads, but may contain others.
|
"active" is undefined. I would rather keep the corrent wording, but perhaps add that the main thread is always there even when finished. |
|
I picked up active from |
|
Hmm, well you see that "active" is a synonym of "alive" in that instance. |
|
There seems to be some distinction between "the thread object is alive" and thread.is_alive() |
|
Perhaps the following will be clear (but more wordy): Return a list of all :class:`Thread` objects currently active. The list
includes daemonic threads, dummy thread objects created by
:func:`current_thread`, and the main thread. It excludes terminated threads
and threads that have not yet been started. However, the main thread
is always part of the result, even when terminated. |
taleinat
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
I think the change in threading.py is unnecessary, but harmless. @iritkatriel, let me know what you think about it, and then we can merge this.
Lib/threading.py
Outdated
| This method returns True just before the run() method starts until just | ||
| after the run() method terminates. The module function enumerate() | ||
| returns a list of all alive threads. | ||
| returns a list that contains all alive threads. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the existing wording is fine here; not sure why this change is need?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's because it may also contain a terminated main thread.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes the new wording correct, but possibly misleading.
The sentence about enumerate() seems somewhat out of place here; perhaps it could just be removed? Otherwise let's add something like "(and always the main thread)" at the end.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps just "see also .."?
Lib/threading.py
Outdated
| This method returns True just before the run() method starts until just | ||
| after the run() method terminates. The module function enumerate() | ||
| returns a list of all alive threads. | ||
| returns a list that contains all alive threads. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes the new wording correct, but possibly misleading.
The sentence about enumerate() seems somewhat out of place here; perhaps it could just be removed? Otherwise let's add something like "(and always the main thread)" at the end.
|
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
|
I have made the requested changes; please review again |
|
Thanks for making the requested changes! @taleinat: please review the changes made to this pull request. |
|
This PR is stale because it has been open for 30 days with no activity. |
|
@iritkatriel, this is definitely ready to be merged. Now that you're a core dev, I'll leave it to you :) |
|
Oh! |
|
@iritkatriel: Please replace |
|
Thanks @iritkatriel for the PR 🌮🎉.. I'm working now to backport this PR to: 3.10, 3.9. |
…on (pythonGH-23192) (cherry picked from commit 12e7d10) Co-authored-by: Irit Katriel <[email protected]>
|
GH-26035 is a backport of this pull request to the 3.10 branch. |
|
GH-26036 is a backport of this pull request to the 3.9 branch. |
…on (pythonGH-23192) (cherry picked from commit 12e7d10) Co-authored-by: Irit Katriel <[email protected]>
…on (GH-23192) (#26035) (cherry picked from commit 12e7d10) Co-authored-by: Irit Katriel <[email protected]>
…on (GH-23192) (#26036) (cherry picked from commit 12e7d10) Co-authored-by: Irit Katriel <[email protected]>
enumerate() returns a list of all active thread objects, which contains all threads for which is_alive is true but may also contain threads (like the main thread) for which is_alive is False.
https://bugs.python.org/issue25821