Skip to content
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

threading.Condition is not a class #57169

Closed
nikratio mannequin opened this issue Sep 11, 2011 · 8 comments
Closed

threading.Condition is not a class #57169

nikratio mannequin opened this issue Sep 11, 2011 · 8 comments
Labels
docs Documentation in the Doc dir type-bug An unexpected behavior, bug, or error

Comments

@nikratio
Copy link
Mannequin

nikratio mannequin commented Sep 11, 2011

BPO 12960
Nosy @birkenfeld, @rhettinger, @vstinner

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2011-09-18.09:38:32.157>
created_at = <Date 2011-09-11.13:37:15.606>
labels = ['type-bug', 'docs']
title = 'threading.Condition is not a class'
updated_at = <Date 2011-09-18.09:38:32.157>
user = 'https://bugs.python.org/nikratio'

bugs.python.org fields:

activity = <Date 2011-09-18.09:38:32.157>
actor = 'vstinner'
assignee = 'docs@python'
closed = True
closed_date = <Date 2011-09-18.09:38:32.157>
closer = 'vstinner'
components = ['Documentation']
creation = <Date 2011-09-11.13:37:15.606>
creator = 'nikratio'
dependencies = []
files = []
hgrepos = []
issue_num = 12960
keywords = []
message_count = 8.0
messages = ['143864', '143996', '143998', '144014', '144018', '144023', '144212', '144215']
nosy_count = 6.0
nosy_names = ['georg.brandl', 'rhettinger', 'vstinner', 'eli.bendersky', 'nikratio', 'docs@python']
pr_nums = []
priority = 'normal'
resolution = 'wont fix'
stage = None
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue12960'
versions = ['Python 2.7', 'Python 3.2']

@nikratio
Copy link
Mannequin Author

nikratio mannequin commented Sep 11, 2011

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.

@nikratio nikratio mannequin assigned docspython Sep 11, 2011
@nikratio nikratio mannequin added docs Documentation in the Doc dir type-bug An unexpected behavior, bug, or error labels Sep 11, 2011
@vstinner
Copy link
Member

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 (bpo-10968): threading.Condition is now a class, instead of a factory.

@nikratio
Copy link
Mannequin Author

nikratio mannequin commented Sep 13, 2011

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

@vstinner
Copy link
Member

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?

@elibendersky
Copy link
Mannequin

elibendersky mannequin commented Sep 14, 2011

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

@nikratio
Copy link
Mannequin Author

nikratio mannequin commented Sep 14, 2011

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

@birkenfeld
Copy link
Member

I don't think this is important enough. It's now a class anyway in 3.3+.

@rhettinger
Copy link
Contributor

I recommend just closing this.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

3 participants