Adds a Thread.getIdent() method to provide the _get_ident() value for

any given threading.Thread object.  feature request issue 2871.
This commit is contained in:
Gregory P. Smith 2008-06-01 23:48:47 +00:00
parent 1bd52d745b
commit 8856ddae25
4 changed files with 28 additions and 2 deletions

View file

@ -3,6 +3,7 @@
import test.test_support
from test.test_support import verbose
import random
import re
import sys
import threading
import thread
@ -72,6 +73,8 @@ class ThreadTests(unittest.TestCase):
for i in range(NUMTASKS):
t = TestThread("<thread %d>"%i, self, sema, mutex, numrunning)
threads.append(t)
self.failUnlessEqual(t.getIdent(), None)
self.assert_(re.match('<TestThread\(.*, initial\)>', repr(t)))
t.start()
if verbose:
@ -79,6 +82,8 @@ class ThreadTests(unittest.TestCase):
for t in threads:
t.join(NUMTASKS)
self.assert_(not t.isAlive())
self.failIfEqual(t.getIdent(), 0)
self.assert_(re.match('<TestThread\(.*, \w+ -?\d+\)>', repr(t)))
if verbose:
print 'all tasks done'
self.assertEqual(numrunning.get(), 0)