STINNER Victor <victor.stin...@haypocalc.com> added the comment:

> In which case can it be None?

Oh, I misunderstood threading.py. current_thread().ident cannot be None.

During the bootstrap of a thread, Thread._ident is None, but 
current_thread().ident is not None because current_thread() creates a dummy 
thread object having the right identifer. This dummy object is destroyed at 
soon as the Thread object is started (see Thread._bootstrap_inner).

current_thread().ident is a little bit "suboptimal" because it gets the 
identifier of the thread, it reads the corresponding thread object, and then it 
gets the identifier of the thread object.

def current_thread():
    ...
    return _active[_get_ident()]
    ...

----------

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

Reply via email to