Skip to content

bpo-29376: Fix assertion error in threading._DummyThread.is_alive() #330

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

Merged
merged 2 commits into from
Feb 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Lib/test/test_threading.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,9 @@ def f(mutex):
mutex.acquire()
self.assertIn(tid, threading._active)
self.assertIsInstance(threading._active[tid], threading._DummyThread)
#Issue 29376
self.assertTrue(threading._active[tid].is_alive())
self.assertRegex(repr(threading._active[tid]), '_DummyThread')
del threading._active[tid]

# PyThreadState_SetAsyncExc() is a CPython-only gimmick, not (currently)
Expand Down
4 changes: 4 additions & 0 deletions Lib/threading.py
Original file line number Diff line number Diff line change
Expand Up @@ -1217,6 +1217,10 @@ def __init__(self):
def _stop(self):
pass

def is_alive(self):
assert not self._is_stopped and self._started.is_set()
return True

def join(self, timeout=None):
assert False, "cannot join a dummy thread"

Expand Down
2 changes: 2 additions & 0 deletions Misc/NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ Extension Modules
Library
-------

- bpo-29376: Fix assertion error in threading._DummyThread.is_alive().

- bpo-28624: Add a test that checks that cwd parameter of Popen() accepts
PathLike objects. Patch by Sayan Chowdhury.

Expand Down