]> granicus.if.org Git - python/commitdiff
bpo-30387: Fix warning in test_threading (#1634)
authorVictor Stinner <victor.stinner@gmail.com>
Wed, 17 May 2017 18:58:50 +0000 (11:58 -0700)
committerGitHub <noreply@github.com>
Wed, 17 May 2017 18:58:50 +0000 (11:58 -0700)
test_is_alive_after_fork() now joins directly the thread to avoid the
following warning added by bpo-30357:

Warning -- threading_cleanup() failed to cleanup 0 threads
after 2 sec (count: 0, dangling: 21)

Use also a different exit code to catch generic exit code 1.

Lib/test/test_threading.py

index 5f7c0a8801cf3ab3349cb43d7074313ad24c6d29..0f3ac555c2dc724c7f546319e8cc3bd5b282bdbe 100644 (file)
@@ -473,13 +473,15 @@ class ThreadTests(BaseTestCase):
         for i in range(20):
             t = threading.Thread(target=lambda: None)
             t.start()
-            self.addCleanup(t.join)
             pid = os.fork()
             if pid == 0:
-                os._exit(1 if t.is_alive() else 0)
+                os._exit(11 if t.is_alive() else 10)
             else:
+                t.join()
+
                 pid, status = os.waitpid(pid, 0)
-                self.assertEqual(0, status)
+                self.assertTrue(os.WIFEXITED(status))
+                self.assertEqual(10, os.WEXITSTATUS(status))
 
     def test_main_thread(self):
         main = threading.main_thread()