summaryrefslogtreecommitdiff
path: root/Lib/test/test_threading.py
diff options
context:
space:
mode:
authorGregory P. Smith <greg@mad-scientist.com>2008-01-22 01:29:11 +0000
committerGregory P. Smith <greg@mad-scientist.com>2008-01-22 01:29:11 +0000
commit8f034d9af2c36cd3451fac5044a700da77a96bd5 (patch)
tree5121fecd95c73f4e204b7aa6122b7ceafa7110a3 /Lib/test/test_threading.py
parent9f26fcce04e8347bef539dcdbc51ad40a56fca18 (diff)
downloadcpython-git-8f034d9af2c36cd3451fac5044a700da77a96bd5.tar.gz
Backport of r60190:
- 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.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/Lib/test/test_threading.py b/Lib/test/test_threading.py
index 8614ecb49c..7c648186f2 100644
--- a/Lib/test/test_threading.py
+++ b/Lib/test/test_threading.py
@@ -3,6 +3,7 @@
import test.test_support
from test.test_support import verbose
import random
+import sys
import threading
import thread
import time
@@ -201,6 +202,24 @@ class ThreadTests(unittest.TestCase):
t.join()
# else the thread is still running, and we have no way to kill it
+ 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)
+
+
def test_main():
test.test_support.run_unittest(ThreadTests)