Issue 31516: current_thread() becomes "dummy" thread during shutdown (original) (raw)

Created on 2017-09-19 11:33 by pitrou, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
mainthread.py pitrou,2017-09-19 11:33
Pull Requests
URL Status Linked Edit
PR 3673 merged pitrou,2017-09-20 16:43
PR 3856 merged python-dev,2017-10-02 14:42
PR 8052 merged ZackerySpytz,2018-07-02 20:10
PR 9813 merged miss-islington,2018-10-12 08:31
PR 9814 merged miss-islington,2018-10-12 08:31
Messages (10)
msg302515 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2017-09-19 11:33
Attaching reproducer. During interpreter shutdown, threading.main_thread() gets marked "stopped" (while it's obviously still running), while threading.current_thread() returns a DummyThread instance with the same ident as the main thread. $ ./python mainthread.py -- before shutdown -- GC in thread <_MainThread(MainThread, started 140359122872064)> main thread is <_MainThread(MainThread, started 140359122872064)> -- during shutdown -- GC in thread <_DummyThread(Dummy-1, started daemon 140359122872064)> main thread is <_MainThread(MainThread, stopped 140359122872064)>
msg302517 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2017-09-19 11:47
The main thread being marked "stopped" at shutdown might be an obscure feature (as hinted in the comments for threading._shutdown()). However, current_thread() should definitely not return a separate DummyThread instance.
msg302637 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2017-09-20 17:00
Tim, any opinion on this one? Do you agree it's an actual bug (if a bit obscure)?
msg302641 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2017-09-20 17:21
Ya, it's clearly best for `current_thread()` to deliver consistent results.
msg303537 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2017-10-02 14:42
New changeset 1023dbbcb7f05e76053486ae7ef7f73b4cdc5398 by Antoine Pitrou in branch 'master': bpo-31516: current_thread() should not return a dummy thread at shutdown (#3673) https://github.com/python/cpython/commit/1023dbbcb7f05e76053486ae7ef7f73b4cdc5398
msg303542 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2017-10-02 15:20
New changeset ac6245a31f9a757db0520722c592cb7fdcb55eb0 by Antoine Pitrou (Miss Islington (bot)) in branch '3.6': [3.6] bpo-31516: current_thread() should not return a dummy thread at shutdown (GH-3673) (#3856) https://github.com/python/cpython/commit/ac6245a31f9a757db0520722c592cb7fdcb55eb0
msg303543 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2017-10-02 15:20
I have now pushed the fix to master and 3.6. Hopefully this won't break anyone's code...
msg327572 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-10-12 08:31
New changeset 65d2f8c044bf597685ba72f66cbcc6b3f7a3ee9c by Serhiy Storchaka (Zackery Spytz) in branch 'master': bpo-31516: Skip test_main_thread_during_shutdown() with COUNT_ALLOCS builds. (GH-8052) https://github.com/python/cpython/commit/65d2f8c044bf597685ba72f66cbcc6b3f7a3ee9c
msg327573 - (view) Author: miss-islington (miss-islington) Date: 2018-10-12 08:49
New changeset c327a5499fa823f627366c17e20687065fd70449 by Miss Islington (bot) in branch '3.7': bpo-31516: Skip test_main_thread_during_shutdown() with COUNT_ALLOCS builds. (GH-8052) https://github.com/python/cpython/commit/c327a5499fa823f627366c17e20687065fd70449
msg327575 - (view) Author: miss-islington (miss-islington) Date: 2018-10-12 08:54
New changeset d918e98056b7ef8d90d71805531cec3e67b5450e by Miss Islington (bot) in branch '3.6': bpo-31516: Skip test_main_thread_during_shutdown() with COUNT_ALLOCS builds. (GH-8052) https://github.com/python/cpython/commit/d918e98056b7ef8d90d71805531cec3e67b5450e
History
Date User Action Args
2022-04-11 14:58:52 admin set github: 75697
2018-10-12 08:54:24 miss-islington set messages: +
2018-10-12 08:49:12 miss-islington set nosy: + miss-islingtonmessages: +
2018-10-12 08:31:40 miss-islington set pull_requests: + <pull%5Frequest9192>
2018-10-12 08:31:34 miss-islington set pull_requests: + <pull%5Frequest9191>
2018-10-12 08:31:28 serhiy.storchaka set nosy: + serhiy.storchakamessages: +
2018-07-02 20:10:56 ZackerySpytz set pull_requests: + <pull%5Frequest7660>
2017-10-02 15:20:39 pitrou set status: open -> closedresolution: fixedmessages: + stage: patch review -> resolved
2017-10-02 15:20:04 pitrou set messages: +
2017-10-02 14:42:32 python-dev set pull_requests: + <pull%5Frequest3836>
2017-10-02 14:42:17 pitrou set messages: +
2017-09-20 17:21:03 tim.peters set messages: +
2017-09-20 17:00:04 pitrou set messages: +
2017-09-20 16:43:35 pitrou set keywords: + patchstage: needs patch -> patch reviewpull_requests: + <pull%5Frequest3662>
2017-09-19 20:55:32 vstinner set nosy: + vstinner
2017-09-19 11:47:18 pitrou set messages: +
2017-09-19 11:33:54 pitrou create