classification
Title: threading.Condition is not a class
Type: behavior Stage:
Components: Documentation Versions: Python 3.2, Python 2.7
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: docs@python Nosy List: docs@python, eli.bendersky, georg.brandl, nikratio, rhettinger, vstinner
Priority: normal Keywords:

Created on 2011-09-11 13:37 by nikratio, last changed 2011-09-18 09:38 by vstinner. This issue is now closed.

Messages (8)
msg143864 - (view) Author: Nikolaus Rath (nikratio) * Date: 2011-09-11 13:37
According to http://docs.python.org/library/threading.html#condition-objects, threading.Condition is a class. However, in fact it turns out to be function that constructs a _Condition instance.

I don't know the reason for that, but it seems to me that either Condition should be a class, or the reason for it being a function should be documented so that people who I would like to inherit from Conditionknow if that is not supported, or if they can safely inherit from _Condition instead.
msg143996 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2011-09-13 23:41
> According to http://docs.python.org/library/threading.html#condition-objects, threading.Condition is a class.

Nope, it's a factory, and it's written in the doc:

"threading.Condition()
A factory function that returns a new condition variable object. A condition variable allows one or more threads to wait until they are notified by another thread.

See Condition Objects."

It has been changed in Python 3.3 (#10968): threading.Condition is now a class, instead of a factory.
msg143998 - (view) Author: Nikolaus Rath (nikratio) * Date: 2011-09-13 23:45
On 09/13/2011 07:41 PM, STINNER Victor wrote:
> 
> STINNER Victor <victor.stinner@haypocalc.com> added the comment:
> 
>> According to http://docs.python.org/library/threading.html#condition-objects, threading.Condition is a class.
> 
> Nope, it's a factory, and it's written in the doc:
> 
> "threading.Condition()
> A factory function that returns a new condition variable object. A condition variable allows one or more threads to wait until they are notified by another thread.
> 
> See Condition Objects."

Yes, but further down it still says:

"""
class threading.Condition([lock])

    If the lock argument is given and not None, [....]
"""

Best,

   -Nikolaus
msg144014 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2011-09-14 08:29
> Yes, but further down it still says:
>
> """
> class threading.Condition([lock])
>
>      If the lock argument is given and not None, [....]
> """

What do you suggest? Replace it by class threading._Condition?
msg144018 - (view) Author: Eli Bendersky (eli.bendersky) * (Python committer) Date: 2011-09-14 09:36
> What do you suggest? Replace it by class threading._Condition?

-1 on this

IMHO just documenting the situation as it is would make more sense
msg144023 - (view) Author: Nikolaus Rath (nikratio) * Date: 2011-09-14 13:16
On 09/14/2011 04:29 AM, STINNER Victor wrote:
> 
> STINNER Victor <victor.stinner@haypocalc.com> added the comment:
> 
>> Yes, but further down it still says:
>>
>> """
>> class threading.Condition([lock])
>>
>>      If the lock argument is given and not None, [....]
>> """
> 
> What do you suggest? Replace it by class threading._Condition?

I don't have an optimal solution that would fit into the prescribed
layout. I think the best we can do is keep calling it class threading
Condition, but mention in the very first sentence that it isn't actually
a class:

class threading.Condition([lock]):

    threading.Condition is not actually a class but a factory function.
    The returned instance, however, is guaranteed to have the behaviour
    of a threading.Condition class as described here.

    If the lock argument...

Best,

   -Nikolaus
msg144212 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2011-09-17 17:47
I don't think this is important enough. It's now a class anyway in 3.3+.
msg144215 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2011-09-17 18:24
I recommend just closing this.
History
Date User Action Args
2011-09-18 09:38:32vstinnersetstatus: open -> closed
resolution: wont fix
2011-09-17 18:24:20rhettingersetnosy: + rhettinger
messages: + msg144215
2011-09-17 17:47:14georg.brandlsetnosy: + georg.brandl
messages: + msg144212
2011-09-15 14:50:33eric.araujosetversions: - Python 2.6, Python 3.1, Python 3.3, Python 3.4
2011-09-14 13:16:51nikratiosetmessages: + msg144023
2011-09-14 09:36:04eli.benderskysetnosy: + eli.bendersky
messages: + msg144018
2011-09-14 08:29:14vstinnersetmessages: + msg144014
2011-09-13 23:45:54nikratiosetmessages: + msg143998
2011-09-13 23:41:31vstinnersetnosy: + vstinner
messages: + msg143996
2011-09-11 13:37:15nikratiocreate