Message342293
> """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. |
|
| Date |
User |
Action |
Args |
| 2019-05-13 09:17:18 | vstinner | set | recipients:
+ vstinner, pitrou, jaketesler |
| 2019-05-13 09:17:18 | vstinner | set | messageid: <[email protected]> |
| 2019-05-13 09:17:18 | vstinner | link | issue36084 messages |
| 2019-05-13 09:17:17 | vstinner | create | |
|