https://github.com/python/cpython/commit/2e3e65380b91124267212114c7f62b85edf6e810
commit: 2e3e65380b91124267212114c7f62b85edf6e810
branch: main
author: Kumar Aditya <[email protected]>
committer: kumaraditya303 <[email protected]>
date: 2025-02-18T12:08:25Z
summary:
improve `test_tasks` to use correct idiom for starting task in asyncio (#130257)
The test should use the correct idiom for starting the task, `loop._run_once`
is private API which should not be used directly, instead use
`asyncio.sleep(0)` for 1 event loop cycle.
files:
M Lib/test/test_asyncio/test_tasks.py
diff --git a/Lib/test/test_asyncio/test_tasks.py
b/Lib/test/test_asyncio/test_tasks.py
index de2e658bca66a0..591b48b88a268c 100644
--- a/Lib/test/test_asyncio/test_tasks.py
+++ b/Lib/test/test_asyncio/test_tasks.py
@@ -2272,10 +2272,8 @@ async def kill_me(loop):
self.assertEqual(self.all_tasks(loop=self.loop), {task})
- asyncio._set_event_loop(None)
-
# execute the task so it waits for future
- self.loop._run_once()
+ self.loop.run_until_complete(asyncio.sleep(0))
self.assertEqual(len(self.loop._ready), 0)
coro = None
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]