mirror of
https://github.com/python/cpython.git
synced 2025-11-03 03:22:27 +00:00
Kill a race in test_threading in which the exception info in a thread finishing
up after it was joined had a traceback pointing to that thread's (deleted) target attribute, while the test was trying to check that the target was destroyed. Big thanks to Antoine Pitrou for diagnosing the race and pointing out sys.exc_clear() to kill the exception early. This fixes issue 2496.
This commit is contained in:
parent
7db15fe9d9
commit
8b9091fba0
2 changed files with 15 additions and 2 deletions
|
|
@ -276,13 +276,17 @@ class ThreadTests(unittest.TestCase):
|
|||
weak_cyclic_object = weakref.ref(cyclic_object)
|
||||
cyclic_object.thread.join()
|
||||
del cyclic_object
|
||||
self.assertEquals(None, weak_cyclic_object())
|
||||
self.assertEquals(None, weak_cyclic_object(),
|
||||
msg=('%d references still around' %
|
||||
sys.getrefcount(weak_cyclic_object())))
|
||||
|
||||
raising_cyclic_object = RunSelfFunction(should_raise=True)
|
||||
weak_raising_cyclic_object = weakref.ref(raising_cyclic_object)
|
||||
raising_cyclic_object.thread.join()
|
||||
del raising_cyclic_object
|
||||
self.assertEquals(None, weak_raising_cyclic_object())
|
||||
self.assertEquals(None, weak_raising_cyclic_object(),
|
||||
msg=('%d references still around' %
|
||||
sys.getrefcount(weak_raising_cyclic_object())))
|
||||
|
||||
|
||||
class ThreadingExceptionTests(unittest.TestCase):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue