STINNER Victor <[email protected]> added the comment:
> """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.
----------
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue36084>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com