summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_asyncio/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_asyncio/utils.py')
-rw-r--r--Lib/test/test_asyncio/utils.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/Lib/test/test_asyncio/utils.py b/Lib/test/test_asyncio/utils.py
index 5b4bb12..ea608f4 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: