GH-78530: add support for generators in asyncio.wait (#102761)

This commit is contained in:
Kumar Aditya 2023-03-17 06:58:43 +05:30 committed by GitHub
parent f33b33eb31
commit 4f5774f648
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 24 additions and 0 deletions

View file

@ -1373,6 +1373,22 @@ class BaseTaskTests:
self.assertEqual(res, 42)
self.assertAlmostEqual(0.15, loop.time())
def test_wait_generator(self):
async def func(a):
return a
loop = self.new_test_loop()
async def main():
tasks = (self.new_task(loop, func(i)) for i in range(10))
done, pending = await asyncio.wait(tasks, return_when=asyncio.ALL_COMPLETED)
self.assertEqual(len(done), 10)
self.assertEqual(len(pending), 0)
loop.run_until_complete(main())
def test_as_completed(self):
def gen():