python_asyncio_course/3_awaitable_objects/task_3_3_11.py
2024-11-02 14:13:39 +03:00

19 lines
386 B
Python

import asyncio
max_counts = {"Counter 1": 13, "Counter 2": 7}
async def counter(name: str, max_count: int):
for i in range(1, max_count + 1):
print(f"{name}: {i}")
await asyncio.sleep(1)
async def main():
tasks = []
for name, value in max_counts.items():
tasks.append(counter(name, value))
await asyncio.gather(*tasks)
asyncio.run(main())