aboutsummaryrefslogtreecommitdiffstatshomepage
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.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/test/test_asyncio/utils.py b/Lib/test/test_asyncio/utils.py
index cb373d544f4..5b4bb123a9e 100644
--- a/Lib/test/test_asyncio/utils.py
+++ b/Lib/test/test_asyncio/utils.py
@@ -1,5 +1,6 @@
"""Utilities shared by tests."""
+import asyncio
import collections
import contextlib
import io
@@ -512,6 +513,18 @@ class TestCase(unittest.TestCase):
if executor is not None:
executor.shutdown(wait=True)
loop.close()
+ policy = support.maybe_get_event_loop_policy()
+ if policy is not None:
+ try:
+ watcher = policy.get_child_watcher()
+ except NotImplementedError:
+ # watcher is not implemented by EventLoopPolicy, e.g. Windows
+ pass
+ else:
+ if isinstance(watcher, asyncio.ThreadedChildWatcher):
+ threads = list(watcher._threads.values())
+ for thread in threads:
+ thread.join()
def set_event_loop(self, loop, *, cleanup=True):
assert loop is not None