Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit be435ae

Browse filesBrowse files
authored
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
1 parent 0770ad9 commit be435ae
Copy full SHA for be435ae

File tree

Expand file treeCollapse file tree

1 file changed

+11
-3
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+11
-3
lines changed

‎Lib/test/test_asyncio/test_windows_events.py

Copy file name to clipboardExpand all lines: Lib/test/test_asyncio/test_windows_events.py
+11-3Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,10 +225,18 @@ def test_read_self_pipe_restart(self):
225225
self.loop.run_forever()
226226
self.loop.stop()
227227
self.loop.run_forever()
228-
# If we don't wait for f to complete here, we may get another
229-
# warning logged about a thread that didn't shut down cleanly.
228+
229+
# Shut everything down cleanly. This is an important part of the
230+
# test - in issue 39010, the error occurred during loop.close(),
231+
# so we want to close the loop during the test instead of leaving
232+
# it for tearDown.
233+
#
234+
# First wait for f to complete to avoid a "future's result was never
235+
# retrieved" error.
230236
self.loop.run_until_complete(f)
231-
self.loop.close()
237+
# Now shut down the loop itself (self.close_loop also shuts down the
238+
# loop's default executor).
239+
self.close_loop(self.loop)
232240
self.assertFalse(self.loop.call_exception_handler.called)
233241

234242

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.