summaryrefslogtreecommitdiff
path: root/Lib/test/test_threading.py
diff options
context:
space:
mode:
authorGregory P. Smith <greg@mad-scientist.com>2008-01-22 01:20:42 +0000
committerGregory P. Smith <greg@mad-scientist.com>2008-01-22 01:20:42 +0000
commit95cd5c0b72db09426f96c8e5716404da01048f93 (patch)
treee689b7c7d35b345d6038825cbad7fa136c4b59f9 /Lib/test/test_threading.py
parent64c5677de4e979d1496d8851dcc27078caa89d40 (diff)
downloadcpython-git-95cd5c0b72db09426f96c8e5716404da01048f93.tar.gz
- 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.
Diffstat (limited to 'Lib/test/test_threading.py')
-rw-r--r--Lib/test/test_threading.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/Lib/test/test_threading.py b/Lib/test/test_threading.py
index 9e2653604c..4f49d7f1cb 100644
--- a/Lib/test/test_threading.py
+++ b/Lib/test/test_threading.py
@@ -236,6 +236,24 @@ class ThreadTests(unittest.TestCase):
"""])
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.