Skip to content

Commit d15fac2

Browse files
[3.12] gh-111644: Fix asyncio test_unhandled_exceptions() (GH-111713) (#111718)
gh-111644: Fix asyncio test_unhandled_exceptions() (GH-111713) Fix test_unhandled_exceptions() of test_asyncio.test_streams: break explicitly a reference cycle. Fix also StreamTests.tearDown(): the loop must not be closed explicitly, but using set_event_loop() which takes care of shutting down the executor with executor.shutdown(wait=True). BaseEventLoop.close() calls executor.shutdown(wait=False). (cherry picked from commit ac01e22) Co-authored-by: Victor Stinner <vstinner@python.org>
1 parent 02f8f78 commit d15fac2

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Lib/test/test_asyncio/test_streams.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ def tearDown(self):
3737
# just in case if we have transport close callbacks
3838
test_utils.run_briefly(self.loop)
3939

40-
self.loop.close()
41-
gc.collect()
40+
# set_event_loop() takes care of closing self.loop in a safe way
4241
super().tearDown()
4342

4443
def _basetest_open_connection(self, open_connection_fut):
@@ -1102,6 +1101,8 @@ async def handle_echo(reader, writer):
11021101

11031102
self.assertEqual(messages[0]['message'],
11041103
'Unhandled exception in client_connected_cb')
1104+
# Break explicitly reference cycle
1105+
messages = None
11051106

11061107

11071108
if __name__ == '__main__':

0 commit comments

Comments
 (0)