mirror of
https://github.com/python/cpython.git
synced 2025-07-28 05:34:31 +00:00
fix Thread.ident when it is the main thread or a dummy thread #5632
This commit is contained in:
parent
a08e8dedc2
commit
d906ea62c8
3 changed files with 22 additions and 1 deletions
|
@ -83,11 +83,24 @@ class ThreadTests(unittest.TestCase):
|
|||
t.join(NUMTASKS)
|
||||
self.assert_(not t.is_alive())
|
||||
self.failIfEqual(t.ident, 0)
|
||||
self.assertFalse(t.ident is None)
|
||||
self.assert_(re.match('<TestThread\(.*, \w+ -?\d+\)>', repr(t)))
|
||||
if verbose:
|
||||
print 'all tasks done'
|
||||
self.assertEqual(numrunning.get(), 0)
|
||||
|
||||
def test_ident_of_no_threading_threads(self):
|
||||
# The ident still must work for the main thread and dummy threads.
|
||||
self.assertFalse(threading.currentThread().ident is None)
|
||||
def f():
|
||||
ident.append(threading.currentThread().ident)
|
||||
done.set()
|
||||
done = threading.Event()
|
||||
ident = []
|
||||
thread.start_new_thread(f, ())
|
||||
done.wait()
|
||||
self.assertFalse(ident[0] is None)
|
||||
|
||||
# run with a small(ish) thread stack size (256kB)
|
||||
def test_various_ops_small_stack(self):
|
||||
if verbose:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue