8000 bpo-39010: Improve test shutdown by bdarnell · Pull Request #22066 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

8000 bpo-39010: Improve test shutdown #22066

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 3, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
8000
Diff view
bpo-39010: Improve test shutdown
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
  • Loading branch information
bdarnell committed Sep 2, 2020
commit de04cce4d5077aa80ce8b65acf5dae17502ba36f
14 changes: 11 additions & 3 deletions Lib/test/test_asyncio/test_windows_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,18 @@ def test_read_self_pipe_restart(self):
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)


Expand Down
0