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 vstinner
Recipients jaketesler, pitrou, vstinner
Date 2019-05-13.09:17:17
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1557739038.03.0.995322564008.issue36084@roundup.psfhosted.org>
In-reply-to
Content
> """Native integral thread ID of this thread or 0 if it has not been started. (...)

Why not set the attribute to None before a thread starts? It would be more consistent with the the "ident" attribute behavior, no? Extract __repr__():

    def __repr__(self):
        assert self._initialized, "Thread.__init__() was not called"
        status = "initial"
        if self._started.is_set():
            status = "started"
        ...
        if self._ident is not None:
            status += " %s" % self._ident
        return "<%s(%s, %s)>" % (self.__class__.__name__, self._name, status)

"is None" is a reliable check to decide if the attribute is set or not.

With the current implementation, it's hard to guess since PyThread_get_thread_native_id() returns on some platforms... But again, I would prefer to not have the attribute if PyThread_get_thread_native_id() is not available on a platform.
History
Date User Action Args
2019-05-13 09:17:18vstinnersetrecipients: + vstinner, pitrou, jaketesler
2019-05-13 09:17:18vstinnersetmessageid: <1557739038.03.0.995322564008.issue36084@roundup.psfhosted.org>
2019-05-13 09:17:18vstinnerlinkissue36084 messages
2019-05-13 09:17:17vstinnercreate