python / python/cpython

Confusing documentation for the `n` parameter of `Threading.Condition.notify(n)`

Open
#117,470 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

docs
Dominant language
Python
Stars
77.2k
Forks
35.9k
PR merge metrics
PR metrics pending

Description

Documentation

I'm confused by this documentation of Threading.Condition.notify(), specifically the n parameter.

[...]

This method wakes up at most n of the threads waiting for the condition variable; it is a no-op if no threads are waiting.

The current implementation wakes up exactly n threads, if at least n threads are waiting. However, it’s not safe to rely on this behavior. A future, optimized implementation may occasionally wake up more than n threads.

[...]

(Boldface added by me.)

So is the contract that it will wake up ≤n threads, or ≥n threads? Is there any guarantee at all?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked Python 3.12 threading.Condition.notify() documentation and read the full description of the n parameter. Clarify the relationship between the stated limit and the current implementation, including whether any guarantee is intended; done means the documentation no longer leaves the contract ambiguous.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.