constructor.
-.. method:: Thread.get_ident()
+.. attribute:: Thread.ident
- Return the 'thread identifier' of this thread or None if the thread has not
- been started. This is a nonzero integer. See the :func:`thread.get_ident()`
+ The 'thread identifier' of this thread or ``None`` if the thread has not been
+ started. This is a nonzero integer. See the :func:`thread.get_ident()`
function. Thread identifiers may be recycled when a thread exits and another
- thread is created. The identifier is returned even after the thread has
+ thread is created. The identifier is available even after the thread has
exited.
for i in range(NUMTASKS):
t = TestThread("<thread %d>"%i, self, sema, mutex, numrunning)
threads.append(t)
- self.failUnlessEqual(t.get_ident(), None)
+ self.failUnlessEqual(t.ident, None)
self.assert_(re.match('<TestThread\(.*, initial\)>', repr(t)))
t.start()
for t in threads:
t.join(NUMTASKS)
self.assert_(not t.is_alive())
- self.failIfEqual(t.get_ident(), 0)
+ self.failIfEqual(t.ident, 0)
self.assert_(re.match('<TestThread\(.*, \w+ -?\d+\)>', repr(t)))
if verbose:
print('all tasks done')
assert self._initialized, "Thread.__init__() not called"
self._name = str(name)
- def get_ident(self):
+ @property
+ def ident(self):
assert self._initialized, "Thread.__init__() not called"
return self._ident