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

Doc mistake : threading.Timer is *not* a class #50081

Closed
maxenced mannequin opened this issue Apr 24, 2009 · 7 comments
Closed

Doc mistake : threading.Timer is *not* a class #50081

maxenced mannequin opened this issue Apr 24, 2009 · 7 comments
Labels
docs Documentation in the Doc dir easy stdlib Python modules in the Lib dir

Comments

@maxenced
Copy link
Mannequin

maxenced mannequin commented Apr 24, 2009

BPO 5831
Nosy @loewis, @birkenfeld, @humitos, @merwok, @keldonin, @bitdancer
Superseder
  • bpo-10968: threading.Timer should be a class so that it can be derived
  • Files
  • threading.Issue.5831.patch
  • 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-01-22.18:32:29.026>
    created_at = <Date 2009-04-24.13:42:36.462>
    labels = ['easy', 'library', 'docs']
    title = 'Doc mistake : threading.Timer is *not* a class'
    updated_at = <Date 2011-02-15.13:23:18.719>
    user = 'https://bugs.python.org/maxenced'

    bugs.python.org fields:

    activity = <Date 2011-02-15.13:23:18.719>
    actor = 'r.david.murray'
    assignee = 'none'
    closed = True
    closed_date = <Date 2011-01-22.18:32:29.026>
    closer = 'eric.araujo'
    components = ['Documentation', 'Library (Lib)']
    creation = <Date 2009-04-24.13:42:36.462>
    creator = 'maxenced'
    dependencies = []
    files = ['14831']
    hgrepos = []
    issue_num = 5831
    keywords = ['patch', 'easy']
    message_count = 7.0
    messages = ['86409', '86413', '92260', '121387', '126848', '128587', '128595']
    nosy_count = 8.0
    nosy_names = ['loewis', 'georg.brandl', 'humitos', 'eric.araujo', 'keldonin', 'r.david.murray', 'maxenced', 'Martijn.van.Oosterhout']
    pr_nums = []
    priority = 'low'
    resolution = 'duplicate'
    stage = 'resolved'
    status = 'closed'
    superseder = '10968'
    type = None
    url = 'https://bugs.python.org/issue5831'
    versions = ['Python 3.1', 'Python 2.7', 'Python 3.2']

    @maxenced
    Copy link
    Mannequin Author

    maxenced mannequin commented Apr 24, 2009

    In the documentation, the Timer() function of the threading class is
    described as a class. however, it's a function :

    >>> import threading
    >>> threading.Timer
    <function Timer at 0x967495c>

    Cheers

    Maxence

    @maxenced maxenced mannequin assigned birkenfeld Apr 24, 2009
    @maxenced maxenced mannequin added the docs Documentation in the Doc dir label Apr 24, 2009
    @bitdancer
    Copy link
    Member

    The Timer function is a simple wrapper for creating an instance of the
    _Timer class.

    The Timer class was proposed in bpo-428326 by Itamar and applied
    by Martin in r22972. In the original patch the class was exposed as
    Timer. Martin's commit introduced the Timer function and _Timer class
    name. The documentation provided by Itamar was not updated to match.

    The change would appear to intentionally make it difficult to create
    Timer subclasses.

    The Timer function/class was added in 2001 and there are no complaints
    that Thread can't be subclassed in the tracker. So perhaps a doc patch
    is appropriate...but that would leave Timer with a name that is not PEP-8 compliant.

    I think I'd prefer deleting the function and naming the class Timer,
    so that it has a PEP-8 compliant name. It seems unlikely that any user
    code would depend on Timer being a function.

    Martin, do you have any memory of why you made Timer a function? Was it
    just that it would be pretty pointless to subclass it?

    @bitdancer bitdancer added easy stdlib Python modules in the Lib dir labels Apr 24, 2009
    @humitos
    Copy link
    Mannequin

    humitos mannequin commented Sep 4, 2009

    I deleted this function and I renamed the class _Timer to Timer. I
    attached the patch

    @admin admin mannequin assigned docspython and unassigned birkenfeld Oct 29, 2010
    @merwok
    Copy link
    Member

    merwok commented Nov 17, 2010

    Nearly all classes in threading uses this function/class indirection, which I don’t understand (except for RLock, which is a factory function).

    @merwok
    Copy link
    Member

    merwok commented Jan 22, 2011

    Explanation has been provided on bpo-10968, and hopefully the code will be cleaned up. Closing as superseded.

    @merwok merwok closed this as completed Jan 22, 2011
    @MartijnvanOosterhout
    Copy link
    Mannequin

    MartijnvanOosterhout mannequin commented Feb 15, 2011

    Note this is a behaviour change. Under the old scheme (Foo is a class)

    Foo.timerclass = Timer

    created a method, whereas now it will just assign the class as an attribute. To work around this you had to use _Timer. Will that dummy class remain as an alias to avoid breaking code (in 2.7 at least)?

    @bitdancer
    Copy link
    Member

    Discussion should be moved to bpo-10968, please.

    @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 easy stdlib Python modules in the Lib dir
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants