[Python-checkins] r60190 - in python/trunk: Lib/test/test_threading.py Lib/threading.py Misc/NEWS
gregory.p.smith
python-checkins at python.org
Tue Jan 22 02:20:42 CET 2008
Author: gregory.p.smith
Date: Tue Jan 22 02:20:42 2008
New Revision: 60190
Modified:
python/trunk/Lib/test/test_threading.py
python/trunk/Lib/threading.py
python/trunk/Misc/NEWS
Log:
- 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.
Modified: python/trunk/Lib/test/test_threading.py
==============================================================================
--- python/trunk/Lib/test/test_threading.py (original)
+++ python/trunk/Lib/test/test_threading.py Tue Jan 22 02:20:42 2008
@@ -236,6 +236,24 @@
"""])
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.
Modified: python/trunk/Lib/threading.py
==============================================================================
--- python/trunk/Lib/threading.py (original)
+++ python/trunk/Lib/threading.py Tue Jan 22 02:20:42 2008
@@ -515,11 +515,14 @@
if __debug__:
self._note("%s.__bootstrap(): normal return", self)
finally:
- self.__stop()
- try:
- self.__delete()
- except:
- pass
+ with _active_limbo_lock:
+ self.__stop()
+ try:
+ # We don't call self.__delete() because it also
+ # grabs _active_limbo_lock.
+ del _active[_get_ident()]
+ except:
+ pass
def __stop(self):
with self.__block:
Modified: python/trunk/Misc/NEWS
==============================================================================
--- python/trunk/Misc/NEWS (original)
+++ python/trunk/Misc/NEWS Tue Jan 22 02:20:42 2008
@@ -371,6 +371,10 @@
- Issue #1537: Changed GeneratorExit's base class from Exception to
BaseException.
+- 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.
+
Library
-------
More information about the Python-checkins
mailing list