Skip to content

Commit c855b53

Browse files
committed
gh-111644: Fix asyncio test_unhandled_exceptions()
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).
1 parent f62c7cc commit c855b53

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Lib/test/test_asyncio/test_streams.py

Lines changed: 3 additions & 2 deletions
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):
@@ -1124,6 +1123,8 @@ async def handle_echo(reader, writer):
11241123

11251124
self.assertEqual(messages[0]['message'],
11261125
'Unhandled exception in client_connected_cb')
1126+
# Break explicitly reference cycle
1127+
messages = None
11271128

11281129

11291130
if __name__ == '__main__':

0 commit comments

Comments
 (0)