提交 78c2acb3 编写于 作者: B Ben Darnell

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.
上级 c3b8ee8d
......@@ -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.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册