New submission from Eric Snow <ericsnowcurren...@gmail.com>:

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.

----------
components: Library (Lib)
messages: 358362
nosy: eric.snow
priority: normal
severity: normal
stage: test needed
status: open
title: Use the runtime's main thread ID in the threading module.
type: behavior
versions: Python 3.9

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue39042>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to