Add 6.5 section task

This commit is contained in:
pro100ton 2024-11-14 22:03:23 +03:00
parent 9066c3cad7
commit ab12d7efc0

16
6_tasks/6_5_03_task.py Normal file
View file

@ -0,0 +1,16 @@
import asyncio
async def process_task():
await asyncio.sleep(1)
cur_task = asyncio.current_task()
return id(cur_task)
async def main():
tasks = [asyncio.create_task(process_task()) for _ in range(0, 10)]
done, tasks = await asyncio.wait(tasks, return_when=asyncio.ALL_COMPLETED)
return [task_res.result() for task_res in done]
asyncio.run(main())