From: Ben Darnell Date: Mon, 19 Jun 2023 19:28:45 +0000 (-0400) Subject: asyncio_test: Use inequality when checking thread leaks X-Git-Tag: v6.4.0b1~27^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=78c2acb33539374ebf1d90e0c1a5b15bdba58cf1;p=thirdparty%2Ftornado.git asyncio_test: Use inequality when checking thread leaks Sometimes we have a net reduction in the thread count because there was an extra thread running at the time captured the starting count, so use inequality instead of exact matches. --- diff --git a/tornado/test/asyncio_test.py b/tornado/test/asyncio_test.py index e4c603aed..4eda9395c 100644 --- a/tornado/test/asyncio_test.py +++ b/tornado/test/asyncio_test.py @@ -171,13 +171,15 @@ class SelectorThreadLeakTest(unittest.TestCase): # For some reason we see transient failures here, but I haven't been able # to catch it to identify which thread is causing it. Whatever thread it # is, it appears to quickly clean up on its own, so just retry a few times. + # At least some of the time the errant thread was running at the time we + # captured self.orig_thread_count, so use inequalities. deadline = time.time() + 1 while time.time() < deadline: threads = list(threading.enumerate()) - if len(threads) == self.orig_thread_count: + if len(threads) <= self.orig_thread_count: break time.sleep(0.1) - self.assertEqual(self.orig_thread_count, len(threads), threads) + self.assertLessEqual(len(threads), self.orig_thread_count, threads) async def dummy_tornado_coroutine(self): # Just access the IOLoop to initialize the selector thread.