summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_asyncio
diff options
context:
space:
mode:
authorBen Darnell <ben@bendarnell.com>2020-09-03 04:58:50 (GMT)
committerGitHub <noreply@github.com>2020-09-03 04:58:50 (GMT)
commitbe435ae2b064dc64f04475bec632862e1dbf605f (patch)
tree1e0fce0cbfc8f065bc390fbc0f34d70e4f8e5e23 /Lib/test/test_asyncio
parent0770ad948cb6d9f7f6c4002efd83e27c27069808 (diff)
downloadcpython-be435ae2b064dc64f04475bec632862e1dbf605f.zip
cpython-be435ae2b064dc64f04475bec632862e1dbf605f.tar.gz
cpython-be435ae2b064dc64f04475bec632862e1dbf605f.tar.bz2
bpo-39010: Improve test shutdown (#22066)
Simply closing the event loop isn't enough to avoid warnings. If we don't also shut down the event loop's default executor, it sometimes logs a "dangling thread" warning. Follow-up to GH-22017
Diffstat (limited to 'Lib/test/test_asyncio')
-rw-r--r--Lib/test/test_asyncio/test_windows_events.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/Lib/test/test_asyncio/test_windows_events.py b/Lib/test/test_asyncio/test_windows_events.py
index 33388a8..f276cd2 100644
--- a/Lib/test/test_asyncio/test_windows_events.py
+++ b/Lib/test/test_asyncio/test_windows_events.py
@@ -225,10 +225,18 @@ class ProactorTests(test_utils.TestCase):
self.loop.run_forever()
self.loop.stop()
self.loop.run_forever()
- # If we don't wait for f to complete here, we may get another
- # warning logged about a thread that didn't shut down cleanly.
+
+ # Shut everything down cleanly. This is an important part of the
+ # test - in issue 39010, the error occurred during loop.close(),
+ # so we want to close the loop during the test instead of leaving
+ # it for tearDown.
+ #
+ # First wait for f to complete to avoid a "future's result was never
+ # retrieved" error.
self.loop.run_until_complete(f)
- self.loop.close()
+ # Now shut down the loop itself (self.close_loop also shuts down the
+ # loop's default executor).
+ self.close_loop(self.loop)
self.assertFalse(self.loop.call_exception_handler.called)