mirror of
https://github.com/python/cpython.git
synced 2025-11-01 06:01:29 +00:00
- Fix Issue #1703448: A joined thread could show up in the
threading.enumerate() list after the join() for a brief period until it actually exited.
This commit is contained in:
parent
64c5677de4
commit
95cd5c0b72
3 changed files with 30 additions and 5 deletions
|
|
@ -236,6 +236,24 @@ def waitingThread():
|
|||
"""])
|
||||
self.assertEqual(rc, 42)
|
||||
|
||||
def test_enumerate_after_join(self):
|
||||
# Try hard to trigger #1703448: a thread is still returned in
|
||||
# threading.enumerate() after it has been join()ed.
|
||||
enum = threading.enumerate
|
||||
old_interval = sys.getcheckinterval()
|
||||
sys.setcheckinterval(1)
|
||||
try:
|
||||
for i in xrange(1, 1000):
|
||||
t = threading.Thread(target=lambda: None)
|
||||
t.start()
|
||||
t.join()
|
||||
l = enum()
|
||||
self.assertFalse(t in l,
|
||||
"#1703448 triggered after %d trials: %s" % (i, l))
|
||||
finally:
|
||||
sys.setcheckinterval(old_interval)
|
||||
|
||||
|
||||
class ThreadingExceptionTests(unittest.TestCase):
|
||||
# A RuntimeError should be raised if Thread.start() is called
|
||||
# multiple times.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue