import asyncio from util import async_timed @async_timed() async def delay(delay_seconds: int) -> int: print(f'засыпаю на {delay_seconds} с') await asyncio.sleep(delay_seconds) print(f'сон в течение {delay_seconds} с закончился') return delay_seconds """ @async_timed() async def main(): task_one = asyncio.create_task(delay(2)) task_two = asyncio.create_task(delay(3)) await task_one await task_two """ @async_timed() async def cpu_bound_work() -> int: counter = 0 for i in range(100000000): counter = counter + 1 return counter # Так делать нет никакого смысла @async_timed() async def main(): sleep_for_three = asyncio.create_task(delay(3)) sleep_again = asyncio.create_task(delay(3)) sleep_once_more = asyncio.create_task(delay(3)) await sleep_for_three await sleep_again await sleep_once_more """ task_one = asyncio.create_task(cpu_bound_work()) print(type(task_one)) result = await task_one print(result) """ """ task_one = asyncio.create_task(cpu_bound_work()) task_two = asyncio.create_task(cpu_bound_work()) await task_one await task_two """ asyncio.run(main())