Skip to content

Commit

Permalink
pythongh-111644: Fix asyncio test_unhandled_exceptions() (python#111713)
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
vstinner authored and Glyphack committed Jan 27, 2024
1 parent 9147bba commit 7e3e96f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Lib/test/test_asyncio/test_streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ def tearDown(self):
# just in case if we have transport close callbacks
test_utils.run_briefly(self.loop)

self.loop.close()
gc.collect()
# set_event_loop() takes care of closing self.loop in a safe way
super().tearDown()

def _basetest_open_connection(self, open_connection_fut):
Expand Down Expand Up @@ -1124,6 +1123,8 @@ async def handle_echo(reader, writer):

self.assertEqual(messages[0]['message'],
'Unhandled exception in client_connected_cb')
# Break explicitly reference cycle
messages = None


if __name__ == '__main__':
Expand Down

0 comments on commit 7e3e96f

Please sign in to comment.