From: Ben Darnell Date: Fri, 16 Dec 2022 20:07:30 +0000 (-0500) Subject: test: Catch error from get_event_loop in tearDown X-Git-Tag: v6.3.0b1~19^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9cbfb7308cc901409e81cc7d3cc7edf17eacd113;p=thirdparty%2Ftornado.git test: Catch error from get_event_loop in tearDown --- diff --git a/tornado/test/asyncio_test.py b/tornado/test/asyncio_test.py index 551a9a8d5..c33d7256b 100644 --- a/tornado/test/asyncio_test.py +++ b/tornado/test/asyncio_test.py @@ -119,7 +119,13 @@ class LeakTest(unittest.TestCase): asyncio.set_event_loop_policy(asyncio.DefaultEventLoopPolicy()) def tearDown(self): - asyncio.get_event_loop_policy().get_event_loop().close() + try: + loop = asyncio.get_event_loop_policy().get_event_loop() + except Exception: + # We may not have a current event loop at this point. + pass + else: + loop.close() asyncio.set_event_loop_policy(self.orig_policy) def test_ioloop_close_leak(self):