msg302515 - (view) |
Author: Antoine Pitrou (pitrou) *  |
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) *  |
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) *  |
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) *  |
Date: 2017-09-20 17:21 |
Ya, it's clearly best for `current_thread()` to deliver consistent results. |
|
|
msg303537 - (view) |
Author: Antoine Pitrou (pitrou) *  |
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) *  |
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) *  |
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) *  |
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 |
|
|