Repository navigation
gh-160326: Raise ValueError for a NaN timeout in Condition.wait() - #160327
Merged
Merged
Conversation
A NaN timeout was treated as zero, which made the deadline loops built on Condition.wait(), such as Queue.get() and Semaphore.acquire(), spin without ever timing out.
gpshead
marked this pull request as ready for review
October 22, 2026 19:19
|
Thanks @gpshead for the PR 🌮🎉.. I'm working now to backport this PR to: 3.14, 3.15. |
|
GH-160416 is a backport of this pull request to the 3.15 branch. |
|
GH-160417 is a backport of this pull request to the 3.14 branch. |
gpshead
added a commit
that referenced
this pull request
Oct 23, 2026
…t() (GH-160327) (#160417) gh-160326: Raise ValueError for a NaN timeout in Condition.wait() (GH-160327) A NaN timeout was treated as zero, which made the deadline loops built on Condition.wait(), such as Queue.get() and Semaphore.acquire(), spin without ever timing out. (cherry picked from commit 3387b19) Co-authored-by: Gregory P. Smith <[email protected]>
gpshead
added a commit
that referenced
this pull request
Oct 23, 2026
…t() (GH-160327) (#160416) gh-160326: Raise ValueError for a NaN timeout in Condition.wait() (GH-160327) A NaN timeout was treated as zero, which made the deadline loops built on Condition.wait(), such as Queue.get() and Semaphore.acquire(), spin without ever timing out. (cherry picked from commit 3387b19) Co-authored-by: Gregory P. Smith <[email protected]>
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Condition.wait()only blocked whentimeout > 0, so a NaN timeout became a non-blocking acquire and every deadline loop on top of it (Queue.get()/put(),Semaphore.acquire(),Condition.wait_for(),Barrier.wait(),as_completed()) spun without ever timing out. Take the non-blocking path only fortimeout <= 0, so that NaN reacheslock.acquire()and gets theValueErrorit already raises.Condition.wait()andEvent.wait()with a NaN timeout used to returnFalseat once and now raise, which is why there is no backport label. The error is only raised when a call has to wait:Queue.get(timeout=nan)on a non-empty queue still succeeds.Fixes #160326
ANT-2026-TIT4IOV6
queue.Queue.get()and otherthreading.Condition.wait()callers busy-loop on a NaN timeout #160326