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.

作者 vstinner
收信人 brett.cannon, docs@python, georg.brandl, pitrou, vstinner
日期 2011-05-16.14:12:18
SpamBayes Score 0.0008696185
Marked as misclassified
Message-id <1305555139.51.0.921637009637.issue12028@psf.upfronthosting.co.za>
In-reply-to
内容
> 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()]
    ...
历史
日期 用户 动作 参数
2011-05-16 14:12:19vstinner修改recipients: + vstinner, brett.cannon, georg.brandl, pitrou, docs@python
2011-05-16 14:12:19vstinner修改messageid: <1305555139.51.0.921637009637.issue12028@psf.upfronthosting.co.za>
2011-05-16 14:12:18vstinner链接issue12028 messages
2011-05-16 14:12:18vstinner创建