()
| 21 | class TestFreeThreading: |
| 22 | def test_all_tasks_race(self) -> None: |
| 23 | async def main(): |
| 24 | loop = asyncio.get_running_loop() |
| 25 | future = loop.create_future() |
| 26 | |
| 27 | async def coro(): |
| 28 | await future |
| 29 | |
| 30 | tasks = set() |
| 31 | |
| 32 | async with asyncio.TaskGroup() as tg: |
| 33 | for _ in range(100): |
| 34 | tasks.add(tg.create_task(coro())) |
| 35 | |
| 36 | all_tasks = asyncio.all_tasks(loop) |
| 37 | self.assertEqual(len(all_tasks), 101) |
| 38 | |
| 39 | for task in all_tasks: |
| 40 | self.assertEqual(task.get_loop(), loop) |
| 41 | self.assertFalse(task.done()) |
| 42 | |
| 43 | current = asyncio.current_task() |
| 44 | self.assertEqual(current.get_loop(), loop) |
| 45 | self.assertSetEqual(all_tasks, tasks | {current}) |
| 46 | future.set_result(None) |
| 47 | |
| 48 | def runner(): |
| 49 | with asyncio.Runner() as runner: |
nothing calls this directly
no test coverage detected