classification
Title: "threading._DummyThread" redefines "is_alive" but forgets "isAlive"
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.8, Python 3.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: asvetlov, brett.cannon, corona10, dmaurer, pmpp, serhiy.storchaka, vstinner
Priority: normal Keywords: patch

Created on 2018-11-20 22:16 by dmaurer, last changed 2019-01-18 14:17 by asvetlov. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 11454 merged corona10, 2019-01-07 08:18
PR 11454 merged corona10, 2019-01-07 08:18
PR 11454 merged corona10, 2019-01-07 08:18
PR 11459 closed corona10, 2019-01-07 15:26
PR 11459 closed corona10, 2019-01-07 15:26
PR 11459 closed corona10, 2019-01-07 15:26
PR 11596 merged corona10, 2019-01-17 23:24
PR 11596 merged corona10, 2019-01-17 23:24
PR 11596 merged corona10, 2019-01-17 23:24
PR 11604 merged corona10, 2019-01-18 09:07
PR 11604 merged corona10, 2019-01-18 09:07
PR 11604 merged corona10, 2019-01-18 09:07
Messages (27)
msg330158 - (view) Author: Dieter Maurer (dmaurer) Date: 2018-11-20 22:16
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".
msg330216 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2018-11-21 21:05
Care to open a PR to fix this?
msg330219 - (view) Author: Dieter Maurer (dmaurer) Date: 2018-11-21 21:31
> 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.
msg330237 - (view) Author: Dong-hee Na (corona10) * (Python triager) Date: 2018-11-22 09:14
Hi, Can I work with this issue if no one works on it?
msg330242 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-11-22 11:25
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.
msg330244 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-11-22 11:27
And since threads support no longer optional, are there reasons to keep _DummyThread?
msg330245 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2018-11-22 11:28
If it's not already deprecated, I'd say deprecate it first.
msg330247 - (view) Author: Dong-hee Na (corona10) * (Python triager) Date: 2018-11-22 11:43
@serhiy.storchaka @pitrou
Then should we add the deprecated message 
for isAlive of class "Thread" first?
msg330248 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2018-11-22 12:02
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.
msg330277 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2018-11-22 19:26
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): https://github.com/python/cpython/blob/3bb183d7fb83ad6a84ec13dea90f95d67be35c69/Lib/threading.py#L1094

@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.
msg330278 - (view) Author: pmp-p (pmpp) * Date: 2018-11-22 19:34
> I guess the question is whether any other Python implementation is threadless?

emscripten python ( cpython on asm.js or webassembly ) is threadless
msg330279 - (view) Author: pmp-p (pmpp) * Date: 2018-11-22 19:37
about micropython, only unix port have thread basic implementation and garbage collector messes with EINTR actually so it is not very useable.

unix port is only one on many, and is the less interesting port apart from running quick simulations.
msg330280 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2018-11-22 20:11
Well, to satisfy everybody we need to:
1. Implement `isAlive` for dummy thread
2. Add a deprecation warning for both Thread.isAlive and _DummyThread.isAlive
3. Remove isAlive in future Python release (3.8 for the deprecation, 3.8+2 for removal).
4. Backporting the property down to 3.7 and 3.6 doesn't hurt, let's do it

Did I miss something?
msg330293 - (view) Author: Dong-hee Na (corona10) * (Python triager) Date: 2018-11-23 02:55
@asvetlov

I agree with asvetlov :)
msg330472 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2018-11-26 22:00
I think the only thing missing from your list, Andrew, is updating docstrings and such to mention is_alive() instead of isAlive().
msg330917 - (view) Author: Dong-hee Na (corona10) * (Python triager) Date: 2018-12-03 09:00
Hi, I am going to solve this issue through below process.

1. Implement `isAlive` for dummy thread
2. Updating docstrings to recommend use is_alive() instead of isAlive().
3. Add a deprecation warning for both Thread.isAlive and _DummyThread.isAlive
4. Remove isAlive in future Python release (3.8 for the deprecation, 3.8+2 for removal).
5. Backporting the property down to 3.7 and 3.6 doesn't hurt, let's do it

Is it okay?
msg330922 - (view) Author: Dieter Maurer (dmaurer) Date: 2018-12-03 09:35
> Hi, I am going to solve this issue through below process.
> ...
> Is it okay?

For me, this would be perfect.
msg333156 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-01-07 14:43
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.
msg333170 - (view) Author: Dong-hee Na (corona10) * (Python triager) Date: 2019-01-07 15:28
@vstinner
Thanks, I've submitted PR 11459 for 3.7 which emit PendingDeprecationWarning.
msg333854 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-01-17 12:14
New changeset 89669ffe10a9db6343f6ee42239e412c8ad96bde by Victor Stinner (Dong-hee Na) in branch 'master':
bpo-35283: Add deprecation warning for Thread.isAlive (GH-11454)
https://github.com/python/cpython/commit/89669ffe10a9db6343f6ee42239e412c8ad96bde
msg333856 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-01-17 12:18
Ok, master now emits a deprecation warning. Is it worth it to emit a pending deprecation warning in Python 3.7?
msg333911 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2019-01-17 23:43
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.
msg333930 - (view) Author: Dong-hee Na (corona10) * (Python triager) Date: 2019-01-18 02:07
Great!
Should we notify this deprecation also on Doc/whatsnew/3.7.rst?
msg333951 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2019-01-18 08:25
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
msg333954 - (view) Author: Dong-hee Na (corona10) * (Python triager) Date: 2019-01-18 09:08
I've upload PR 11604
Thanks always
msg333955 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-01-18 09:50
New changeset 36d9e9a4d5238d5a2f09679b6c51be66fbfc12c4 by Victor Stinner (Dong-hee Na) in branch 'master':
bpo-35283: Update the docstring of threading.Thread.join method (GH-11596)
https://github.com/python/cpython/commit/36d9e9a4d5238d5a2f09679b6c51be66fbfc12c4
msg333966 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-01-18 14:09
New changeset c2647f2e45d2741fc44fd621966e05d15f2cd26a by Victor Stinner (Dong-hee Na) in branch '3.7':
bpo-35283: Add pending deprecation warning for Thread.isAlive (GH-11604)
https://github.com/python/cpython/commit/c2647f2e45d2741fc44fd621966e05d15f2cd26a
History
Date User Action Args
2019-01-18 14:17:47asvetlovsetstatus: open -> closed
stage: patch review -> resolved
resolution: fixed
versions: + Python 3.7, Python 3.8
2019-01-18 14:09:48vstinnersetmessages: + msg333966
2019-01-18 09:50:51vstinnersetmessages: + msg333955
2019-01-18 09:08:50corona10setmessages: + msg333954
2019-01-18 09:07:51corona10setpull_requests: + pull_request11328
2019-01-18 09:07:37corona10setpull_requests: + pull_request11327
2019-01-18 09:07:22corona10setpull_requests: + pull_request11326
2019-01-18 08:25:00asvetlovsetmessages: + msg333951
2019-01-18 08:17:24pitrousetnosy: - pitrou
2019-01-18 02:07:28corona10setmessages: + msg333930
2019-01-17 23:43:33asvetlovsetmessages: + msg333911
2019-01-17 23:25:00corona10setpull_requests: + pull_request11303
2019-01-17 23:24:48corona10setpull_requests: + pull_request11302
2019-01-17 23:24:33corona10setpull_requests: + pull_request11301
2019-01-17 12:18:49vstinnersetmessages: + msg333856
2019-01-17 12:14:50vstinnersetmessages: + msg333854
2019-01-07 15:28:14corona10setmessages: + msg333170
2019-01-07 15:26:24corona10setpull_requests: + pull_request10933
2019-01-07 15:26:12corona10setpull_requests: + pull_request10932
2019-01-07 15:26:01corona10setpull_requests: + pull_request10931
2019-01-07 14:43:44vstinnersetnosy: + vstinner
messages: + msg333156
2019-01-07 08:19:27corona10setpull_requests: + pull_request10923
2019-01-07 08:19:12corona10setpull_requests: + pull_request10922
2019-01-07 08:18:56corona10setpull_requests: + pull_request10921
2018-12-03 09:35:58dmaurersetmessages: + msg330922
2018-12-03 09:00:25corona10setmessages: + msg330917
2018-11-26 22:00:26brett.cannonsetmessages: + msg330472
2018-11-23 02:55:58corona10setmessages: + msg330293
2018-11-22 20:11:08asvetlovsetmessages: + msg330280
2018-11-22 19:37:00pmppsetmessages: + msg330279
2018-11-22 19:34:42pmppsetnosy: + pmpp
messages: + msg330278
2018-11-22 19:26:33brett.cannonsetmessages: + msg330277
2018-11-22 12:02:34asvetlovsetnosy: + asvetlov
messages: + msg330248
2018-11-22 11:43:34corona10setmessages: + msg330247
2018-11-22 11:41:47corona10setpull_requests: - pull_request9906
2018-11-22 11:28:20pitrousetmessages: + msg330245
2018-11-22 11:27:44serhiy.storchakasetnosy: + pitrou
messages: + msg330244
2018-11-22 11:25:16serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg330242
2018-11-22 11:16:07corona10setkeywords: + patch
stage: patch review
pull_requests: + pull_request9906
2018-11-22 09:14:11corona10setnosy: + corona10
messages: + msg330237
2018-11-21 21:31:32dmaurersetmessages: + msg330219
2018-11-21 21:05:16brett.cannonsettype: crash -> behavior
2018-11-21 21:05:00brett.cannonsetnosy: + brett.cannon
messages: + msg330216
2018-11-20 22:16:29dmaurercreate