From 079931d12223ec98cbf53185b90db48efa61f93f Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Thu, 19 Sep 2019 16:45:06 +0200 Subject: bpo-34037: test_asyncio uses shutdown_default_executor() (GH-16284) --- Lib/test/test_asyncio/utils.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'Lib/test/test_asyncio/utils.py') diff --git a/Lib/test/test_asyncio/utils.py b/Lib/test/test_asyncio/utils.py index 5b4bb123a9..ea608f4a10 100644 --- a/Lib/test/test_asyncio/utils.py +++ b/Lib/test/test_asyncio/utils.py @@ -509,9 +509,11 @@ def get_function_source(func): class TestCase(unittest.TestCase): @staticmethod def close_loop(loop): - executor = loop._default_executor - if executor is not None: - executor.shutdown(wait=True) + if loop._default_executor is not None: + if not loop.is_closed(): + loop.run_until_complete(loop.shutdown_default_executor()) + else: + loop._default_executor.shutdown(wait=True) loop.close() policy = support.maybe_get_event_loop_policy() if policy is not None: -- cgit v1.2.1