MCPcopy Index your code
hub / github.com/python/cpython / main

Method main

Lib/test/test_asyncio/test_free_threading.py:23–46  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

21class 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:

Callers

nothing calls this directly

Calls 15

setFunction · 0.85
strFunction · 0.85
assertFalseMethod · 0.80
assertSetEqualMethod · 0.80
assertIsInstanceMethod · 0.80
create_futureMethod · 0.45
addMethod · 0.45
create_taskMethod · 0.45
assertEqualMethod · 0.45
get_loopMethod · 0.45
doneMethod · 0.45
set_resultMethod · 0.45

Tested by

no test coverage detected