This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author eric.snow
Recipients eric.snow
Date 2019-12-13.22:21:21
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1576275682.19.0.998306709118.issue39042@roundup.psfhosted.org>
In-reply-to
Content
The threading module has a "main_thread()" function that returns a Thread instance for the "main" thread.  The main thread is the one running when the runtime is initialized and has a specific role in various parts of the runtime.  Currently the threading module instead uses the ID of the thread where the module is imported for the first time.  Usually this isn't a problem. (perhaps only in embedding cases?)

Since 3.8 we store the ID of the thread where the runtime was initialized (_PyRuntime.main_thread).  By using this in the threading module we can be consistent across the runtime about what the main thread is.

This is particularly significant because in 3.8 we also updated the signal module to use _PyRuntime.main_thread (instead of calling PyThread_get_thread_ident() when the module is loaded).  See issue38904.

We should also consider backporting this change to 3.8, to resolve the difference between the threading and signal modules.
History
Date User Action Args
2019-12-13 22:21:22eric.snowsetrecipients: + eric.snow
2019-12-13 22:21:22eric.snowsetmessageid: <1576275682.19.0.998306709118.issue39042@roundup.psfhosted.org>
2019-12-13 22:21:22eric.snowlinkissue39042 messages
2019-12-13 22:21:21eric.snowcreate