Skip to content

"threading._DummyThread" redefines "is_alive" but forgets "isAlive" #79464

Closed

Description

@d-maurer
mannequin
BPO 35283
Nosy @brettcannon, @d-maurer, @vstinner, @asvetlov, @pmp-p, @serhiy-storchaka, @corona10
PRs
  • bpo-35283: Add a deprecated warning for the threading.Thread.isAlive #11454
  • bpo-35283: Add a deprecated warning for the threading.Thread.isAlive #11454
  • bpo-35283: Add a deprecated warning for the threading.Thread.isAlive #11454
  • [3.7] bpo-35283: Add a deprecated warning for the threading.Thread.isAlive #11459
  • [3.7] bpo-35283: Add a deprecated warning for the threading.Thread.isAlive #11459
  • [3.7] bpo-35283: Add a deprecated warning for the threading.Thread.isAlive #11459
  • bpo-35283: Update the docstring of threading.Thread.join method #11596
  • bpo-35283: Update the docstring of threading.Thread.join method #11596
  • bpo-35283: Update the docstring of threading.Thread.join method #11596
  • [3.7] bpo-35283: Add deprecation warning for Thread.isAlive (GH-11454) #11604
  • [3.7] bpo-35283: Add deprecation warning for Thread.isAlive (GH-11454) #11604
  • [3.7] bpo-35283: Add deprecation warning for Thread.isAlive (GH-11454) #11604
  • 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 2019-01-18.14:17:47.552>
    created_at = <Date 2018-11-20.22:16:29.238>
    labels = ['3.7', '3.8', 'type-bug', 'library']
    title = '"threading._DummyThread" redefines "is_alive" but forgets "isAlive"'
    updated_at = <Date 2019-01-18.14:17:47.547>
    user = 'https://github.com/d-maurer'

    bugs.python.org fields:

    activity = <Date 2019-01-18.14:17:47.547>
    actor = 'asvetlov'
    assignee = 'none'
    closed = True
    closed_date = <Date 2019-01-18.14:17:47.552>
    closer = 'asvetlov'
    components = ['Library (Lib)']
    creation = <Date 2018-11-20.22:16:29.238>
    creator = 'dmaurer'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 35283
    keywords = ['patch']
    message_count = 27.0
    messages = ['330158', '330216', '330219', '330237', '330242', '330244', '330245', '330247', '330248', '330277', '330278', '330279', '330280', '330293', '330472', '330917', '330922', '333156', '333170', '333854', '333856', '333911', '333930', '333951', '333954', '333955', '333966']
    nosy_count = 7.0
    nosy_names = ['brett.cannon', 'dmaurer', 'vstinner', 'asvetlov', 'pmpp', 'serhiy.storchaka', 'corona10']
    pr_nums = ['11454', '11454', '11454', '11459', '11459', '11459', '11596', '11596', '11596', '11604', '11604', '11604']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue35283'
    versions = ['Python 3.7', 'Python 3.8']

    Activity

    1. d-maurer commented on Nov 20, 2018

      d-maurermannequin
      MannequinAuthor

      In module "threading", class "Thread" defines "is_alive" and defines "isAlive = is_alive". The derived class "_DummyThread" redefines "is_alive" but forgets to update the "isAlive" alias. As a consequence, calling "_DummyThread.isAlive" leads to an "AssertionErrror".

      The "isAlive" method is mentioned in the docstring of "Thread.join".

    2. added
      type-crashA hard crash of the interpreter, possibly with a core dump
      stdlibStandard Library Python modules in the Lib/ directory
      on Nov 20, 2018
    3. brettcannon commented on Nov 21, 2018

      @brettcannon
      Member

      Care to open a PR to fix this?

    4. added
      type-bugAn unexpected behavior, bug, or error
      and removed
      type-crashA hard crash of the interpreter, possibly with a core dump
      on Nov 21, 2018
    5. d-maurer commented on Nov 21, 2018

      d-maurermannequin
      MannequinAuthor

      Care to open a PR to fix this?

      I am not familiar with the "github" workflow. The fix is so trivial (add the "isAlive = is_alive" alias to "threading._DummyThread" and replace "isAlive" by "is_alive" in the docstring of "threading.Thread.join" that it does not seem worth to learn the "github" workflow just for this fix.

    6. corona10 commented on Nov 22, 2018

      @corona10
      Member

      Hi, Can I work with this issue if no one works on it?

    7. serhiy-storchaka commented on Nov 22, 2018

      @serhiy-storchaka
      Member

      isAlive() is the part of the old API. It is not even documented in Python 3, and can be removed in future. It is better to remove it from docstrings.

    8. serhiy-storchaka commented on Nov 22, 2018

      @serhiy-storchaka
      Member

      And since threads support no longer optional, are there reasons to keep _DummyThread?

    9. pitrou commented on Nov 22, 2018

      @pitrou
      Member

      If it's not already deprecated, I'd say deprecate it first.

    10. corona10 commented on Nov 22, 2018

      @corona10
      Member

      @serhiy.storchaka @pitrou
      Then should we add the deprecated message
      for isAlive of class "Thread" first?

    11. asvetlov commented on Nov 22, 2018

      @asvetlov
      Contributor

      The only _DummyThread usage is threading.current_thread():

      If the caller's thread of control was not created through the threading
      module, a dummy thread object with limited functionality is returned.

    12. brettcannon commented on Nov 22, 2018

      @brettcannon
      Member

      I guess the question is whether any other Python implementation is threadless? E.g. is MicroPython? If it even has threads then I agree about deprecating the module.

      But if MicroPython does support threads we should keep the module. That would mean updating all references of isAlive() to is_alive() and adding the name alias since that name aliasing still exists in 'master' right now (probably for Python 2 porting support):

      isAlive = is_alive

      @dmaurer totally understand about time restraints, but do realize even "trivial" fixes like this would still take at least an hour to do a proper job so there's no guarantee someone will get around to fixing this. But if you do change your mind and want to give it a try, then https://devguide.python.org/ is there to help.

    13. pmp-p commented on Nov 22, 2018

      pmp-pmannequin
      Mannequin

      I guess the question is whether any other Python implementation is threadless?

      emscripten python ( cpython on asm.js or webassembly ) is threadless

    14. 5 remaining items

    15. d-maurer commented on Dec 3, 2018

      d-maurermannequin
      MannequinAuthor

      Hi, I am going to solve this issue through below process.
      ...
      Is it okay?

      For me, this would be perfect.

    16. vstinner commented on Jan 7, 2019

      @vstinner
      Member

      I suggest to start with:

      • Updating docstrings to recommend use is_alive() instead of isAlive(), and add a deprecation warning for Thread.isAlive

      We may apply such changes to Python 3.7, maybe also emit a PendingDeprecationWarning.

    17. corona10 commented on Jan 7, 2019

      @corona10
      Member

      @vstinner
      Thanks, I've submitted PR 11459 for 3.7 which emit PendingDeprecationWarning.

    18. vstinner commented on Jan 17, 2019

      @vstinner
      Member

      New changeset 89669ff by Victor Stinner (Dong-hee Na) in branch 'master':
      bpo-35283: Add deprecation warning for Thread.isAlive (GH-11454)
      89669ff

    19. vstinner commented on Jan 17, 2019

      @vstinner
      Member

      Ok, master now emits a deprecation warning. Is it worth it to emit a pending deprecation warning in Python 3.7?

    20. asvetlov commented on Jan 17, 2019

      @asvetlov
      Contributor

      I think yes.
      People will be notified about depreciation earlier, even after 3.8 release not everybody switches to a new version fast.
      For example, I still use 3.6 for my job now (but we are planning to switch to 3.7 in a month or two).
      Adding PendingDeprecationWarning to 3.7 is safe, I expect a very few code uses .isAlive() on Python 3.

    21. corona10 commented on Jan 18, 2019

      @corona10
      Member

      Great!
      Should we notify this deprecation also on Doc/whatsnew/3.7.rst?

    22. asvetlov commented on Jan 18, 2019

      @asvetlov
      Contributor

      Not sure. IMHO it is not a *notable* change worth to be mentioned in https://docs.python.org/3/whatsnew/3.7.html#notable-changes-in-python-3-7-2

    23. corona10 commented on Jan 18, 2019

      @corona10
      Member

      I've upload PR 11604
      Thanks always

    24. vstinner commented on Jan 18, 2019

      @vstinner
      Member

      New changeset 36d9e9a by Victor Stinner (Dong-hee Na) in branch 'master':
      bpo-35283: Update the docstring of threading.Thread.join method (GH-11596)
      36d9e9a

    25. vstinner commented on Jan 18, 2019

      @vstinner
      Member

      New changeset c2647f2 by Victor Stinner (Dong-hee Na) in branch '3.7':
      bpo-35283: Add pending deprecation warning for Thread.isAlive (GH-11604)
      c2647f2

    26. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      3.7 (EOL)end of life3.8 (EOL)end of lifestdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions