]> granicus.if.org Git - python/commitdiff
bpo-31234: Join threads in test_threading (#3579)
authorVictor Stinner <victor.stinner@gmail.com>
Thu, 14 Sep 2017 20:05:21 +0000 (13:05 -0700)
committerGitHub <noreply@github.com>
Thu, 14 Sep 2017 20:05:21 +0000 (13:05 -0700)
Call thread.join() to prevent the "dangling thread" warning.

Lib/test/test_threading.py

index 912eb3fa67a6c5fcf146828ee28433c07043d343..ab383c23332b0992b63f9dae4ebe4b215f04915f 100644 (file)
@@ -578,6 +578,7 @@ class ThreadTests(BaseTestCase):
         self.assertFalse(t.is_alive())
         # And verify the thread disposed of _tstate_lock.
         self.assertIsNone(t._tstate_lock)
+        t.join()
 
     def test_repr_stopped(self):
         # Verify that "stopped" shows up in repr(Thread) appropriately.
@@ -604,6 +605,7 @@ class ThreadTests(BaseTestCase):
                 break
             time.sleep(0.01)
         self.assertIn(LOOKING_FOR, repr(t)) # we waited at least 5 seconds
+        t.join()
 
     def test_BoundedSemaphore_limit(self):
         # BoundedSemaphore should raise ValueError if released too often.
@@ -918,6 +920,7 @@ class ThreadingExceptionTests(BaseTestCase):
         thread = threading.Thread()
         thread.start()
         self.assertRaises(RuntimeError, thread.start)
+        thread.join()
 
     def test_joining_current_thread(self):
         current_thread = threading.current_thread()
@@ -931,6 +934,7 @@ class ThreadingExceptionTests(BaseTestCase):
         thread = threading.Thread()
         thread.start()
         self.assertRaises(RuntimeError, setattr, thread, "daemon", True)
+        thread.join()
 
     def test_releasing_unacquired_lock(self):
         lock = threading.Lock()