Coverage for docs_src/tutorial/soonify_return/tutorial001.py: 100%
18 statements
« prev ^ index » next coverage.py v7.6.1, created at 2024-09-09 01:12 +0000
« prev ^ index » next coverage.py v7.6.1, created at 2024-09-09 01:12 +0000
1import anyio 1abcde
2import asyncer 1abcde
5async def do_work(name: str): 1abcde
6 await anyio.sleep(1) 1abcde
7 message = f"Hello, {name}" 1abcde
8 return message 1abcde
11async def get_data(): 1abcde
12 async with asyncer.create_task_group() as task_group: 1abcde
13 soon_value1 = task_group.soonify(do_work)(name="Yury") 1abcde
14 soon_value2 = task_group.soonify(do_work)(name="Nathaniel") 1abcde
15 soon_value3 = task_group.soonify(do_work)(name="Alex") 1abcde
17 data = [soon_value1.value, soon_value2.value, soon_value3.value] 1abcde
18 return data 1abcde
21async def main(): 1abcde
22 data = await get_data() 1abcde
23 for message in data: 1abcde
24 print(message) 1abcde
27anyio.run(main) 1abcde