8000 Doc: Clarify the return type of Event.wait when timeout is used. by pelson · Pull Request #104168 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

Doc: Clarify the return type of Event.wait when timeout is used. #104168

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

Merged
merged 5 commits into from
Feb 26, 2024
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions Doc/library/threading.rst
Original file line number Diff line number Diff line change
Expand Up @@ -996,9 +996,8 @@ method. The :meth:`~Event.wait` method blocks until the flag is true.
(or fractions thereof).

This method returns ``True`` if and only if the internal flag has been set to
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"if the internal flag has been set" is vague. In practice, it means that the set() method was called, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that is is vague. I would also like to use that style of language, rather than talking about internal flags tbh.

I've re-written the docstring entirely based on the reviews, but haven't yet used the simpler language you suggested - the only hesitation is that we have to also mention clear() and the fact that set() may have been called before wait() if we want to be 100% precise (I'm not sure it helps with clarity to be so precise though).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The wait entry immediately follows the set and clear entries, so I think it should be clear enough that those are the functions for manipulating the 'internal flag'.

true, either before the wait call or after the wait starts, so it will
always return ``True`` except if a timeout is given and the operation
times out.
true, either before the wait call or after the wait starts.
If a timeout is given and the operation times out, ``False`` will be returned.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand what is the expected return value if no timeout is given and set() was not called: the function just doesn't return and block until set() is called?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Several paragraphs above:

      Block until the internal flag is true.  If the internal flag is true on
      entry, return immediately.  Otherwise, block until another thread calls
      :meth:`.set` to set the flag to true, or until the optional timeout occurs.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My rewrite combines paragraphs is a way that I think is clearer in less words. I think this ready to merge now.


.. versionchanged:: 3.1
Previously, the method always returned ``None``.
Expand Down
0