From a45eb76421a6ef527a1a488fc974df56ed985857 Mon Sep 17 00:00:00 2001 From: mhchia Date: Mon, 9 Sep 2019 22:52:47 +0800 Subject: [PATCH] Suppress all exceptions in clean up. --- tests/utils.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/utils.py b/tests/utils.py index a26ebc55..8ae72d66 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -17,6 +17,7 @@ async def connect(node1, node2): await node1.connect(info) +# FIXME: Should be deprecated, since it also kills the main task. async def cleanup(): pending = asyncio.all_tasks() for task in pending: @@ -24,7 +25,9 @@ async def cleanup(): # Now we should await task to execute it's cancellation. # Cancelled task raises asyncio.CancelledError that we can suppress: - with suppress(asyncio.CancelledError): + # NOTE: Changed from `asyncio.CancelledError` to `Exception`, to suppress all exceptions + # including the one in `run_until_complete`. + with suppress(Exception): await task