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.

classification
Title: Bug - threading.currentThread().ident returns None in main thread
Type: behavior Stage: needs patch
Components: Library (Lib) Versions: Python 3.0, Python 3.1, Python 2.7, Python 2.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: benjamin.peterson, skip.montanaro
Priority: normal Keywords: patch

Created on 2009-03-31 21:01 by skip.montanaro, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
threading.diff skip.montanaro, 2009-03-31 21:16
Messages (3)
msg84901 - (view) Author: Skip Montanaro (skip.montanaro) * (Python triager) Date: 2009-03-31 21:01
The main thread has an ident, but the threading module doesn't
recognize that fact.  I shouldn't have to "start" the main thread.

Example:

% python
Python 2.7a0 (trunk:70084, Feb 28 2009, 20:51:51) 
[GCC 4.0.1 (Apple Inc. build 5490)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import threading
>>> import thread
>>> print threading.currentThread(), threading.currentThread().ident, 
thread.get_ident()
<_MainThread(MainThread, started)> None -1602627808

% python3.1
Python 3.1a0 (py3k:70084M, Feb 28 2009, 20:46:48) 
[GCC 4.0.1 (Apple Inc. build 5490)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import threading  
>>> print (threading.current_thread(), 
threading.current_thread().ident)<_MainThread(MainThread, started)> None
msg84909 - (view) Author: Skip Montanaro (skip.montanaro) * (Python triager) Date: 2009-03-31 21:16
Here's a test case which reveals the problem as I see it.
msg84918 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2009-03-31 21:34
Fixed in r70897.
History
Date User Action Args
2022-04-11 14:56:47adminsetgithub: 49882
2009-03-31 21:34:53benjamin.petersonsetstatus: open -> closed

nosy: + benjamin.peterson
messages: + msg84918

resolution: fixed
2009-03-31 21:16:20skip.montanarosetfiles: + threading.diff
keywords: + patch
messages: + msg84909

stage: needs patch
2009-03-31 21:01:37skip.montanarocreate