This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: document threading.Condition.notify
Type: behavior Stage: resolved
Components: Documentation Versions: Python 3.2, Python 3.3, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: docs@python, eli.bendersky, ezio.melotti, gjcross, pitrou, python-dev, r.david.murray
Priority: normal Keywords: easy, patch

Created on 2011-08-17 02:37 by eli.bendersky, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
issue12767.1.patch eli.bendersky, 2011-11-12 04:50
issue12767.2.patch eli.bendersky, 2011-11-12 05:53
Messages (13)
msg142246 - (view) Author: Eli Bendersky (eli.bendersky) * (Python committer) Date: 2011-08-17 02:37
User report (Jiachang Xu) from the docs mailing list:

The theading.Condition.notify method has a parameter - n, which isn't documented in the the documentation of the threading module.

1. The parameter should be documented
2. notify() is mentioned multiple times in the docs of threading - perhaps the parameter should be mentioned in more than one place as well
3. The parameter should also be documented in the doc-string of notify in Lib/theading.py - however, this may be a separate issue since currently none of the methods of Condition has docstrings.
msg142248 - (view) Author: Eli Bendersky (eli.bendersky) * (Python committer) Date: 2011-08-17 02:43
Opened Issue 12768 on the general lack of docstrings in the threading module
msg142264 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2011-08-17 11:09
From a quick look at the code and docs I suspect that 'n' is an internal implementation detail and not meant to be exposed.  Is there an use case for notifying waiters where n!=1 and n!=len(waiters)?  If my speculation is correct it might be a good idea to refactor this so that notify itself does not take an argument but instead both it an notify_all call an explicitly internal routine _notify.
msg142266 - (view) Author: Eli Bendersky (eli.bendersky) * (Python committer) Date: 2011-08-17 11:21
David, while you make a valid point, consider that 'n' is part of the public API of the threading module (although not documented) and it's conceivable that there is existing code "in the wild" using it. To do what you suggest we should maybe go through a normal deprecation process for this argument first?

Adding Antoine as the listed threading expert.
msg142271 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2011-08-17 12:36
Good point.  Probably, then, we should just put a comment in the code that 'n' is an internal implementation detail and leave it at that.
msg142301 - (view) Author: Eli Bendersky (eli.bendersky) * (Python committer) Date: 2011-08-18 02:30
I asked the user who reported this documentation omission what he's using the 'n' argument for. His reply:

    "Yes I am using the n parameter, it is mainly to implement a subclass of Queue that supports "bulk" get and put operations. This enhances the performance of repeated get/put calls when the Queue is created using multiprocessing.Manager."
msg142307 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2011-08-18 09:26
> I asked the user who reported this documentation omission what he's
> using the 'n' argument for. His reply:
> 
>     "Yes I am using the n parameter, it is mainly to implement a
> subclass of Queue that supports "bulk" get and put operations. This
> enhances the performance of repeated get/put calls when the Queue is
> created using multiprocessing.Manager."

I think it's fine to document it. It's been there for a long time.
Besides, if we know how to notify one thread, we are certainly able to
notify n of them :)
msg142669 - (view) Author: Graeme Cross (gjcross) Date: 2011-08-22 04:56
I have added documentation for the 'n' parameter of threading.Condition.notify as part of the overhaul of the threading module's docstrings.

Reference: #12768
msg147463 - (view) Author: Eli Bendersky (eli.bendersky) * (Python committer) Date: 2011-11-12 04:50
I propose the attached patch for the documentation. Any objections?
msg147466 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2011-11-12 05:49
+      This method wakes up at most *n* of the threads
+      The current implementation wakes up exactly *n* threads
+      A future, optimized implementation may occasionally wake up more than
+      one thread.

Isn't this a bit contradictory?
msg147468 - (view) Author: Eli Bendersky (eli.bendersky) * (Python committer) Date: 2011-11-12 05:53
Ezio, thanks for the catch. I missed that one. Attaching a new, fixed patch.
msg147517 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2011-11-12 18:37
New changeset 63a24bff6f36 by Eli Bendersky in branch '3.2':
Issue #12767: documenting threading.Condition.notify
http://hg.python.org/cpython/rev/63a24bff6f36

New changeset ac12dcea69e1 by Eli Bendersky in branch 'default':
Issue 12767: document the argument of threading.Condition.notify
http://hg.python.org/cpython/rev/ac12dcea69e1
msg147518 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2011-11-12 18:42
New changeset 63a00d019bb2 by Eli Bendersky in branch '2.7':
Closes issue 12767: document the argument of threading.Condition.notify
http://hg.python.org/cpython/rev/63a00d019bb2
History
Date User Action Args
2022-04-11 14:57:20adminsetgithub: 56976
2011-11-12 18:42:01python-devsetstatus: open -> closed
resolution: fixed
messages: + msg147518

stage: patch review -> resolved
2011-11-12 18:37:09python-devsetnosy: + python-dev
messages: + msg147517
2011-11-12 05:53:36eli.benderskysetfiles: + issue12767.2.patch

messages: + msg147468
2011-11-12 05:49:10ezio.melottisetnosy: + ezio.melotti

messages: + msg147466
stage: needs patch -> patch review
2011-11-12 04:50:34eli.benderskysetfiles: + issue12767.1.patch
keywords: + patch
messages: + msg147463
2011-08-22 04:56:15gjcrosssetnosy: + gjcross
messages: + msg142669
2011-08-18 09:26:03pitrousetmessages: + msg142307
2011-08-18 02:30:54eli.benderskysetmessages: + msg142301
2011-08-17 12:36:06r.david.murraysetmessages: + msg142271
2011-08-17 11:21:18eli.benderskysetnosy: + pitrou
messages: + msg142266
2011-08-17 11:09:12r.david.murraysetnosy: + r.david.murray
messages: + msg142264
2011-08-17 02:43:44eli.benderskysetmessages: + msg142248
2011-08-17 02:37:09eli.benderskycreate