import asyncio
import random
from itertools import count
async def describe(description: str) -> str:
await asyncio.sleep(random.random() / 10)
print(description)
return description
async def main() -> None:
descriptions = [
describe("Simulation Engineer"),
describe("Python Developer"),
describe("Rust Enthusiast"),
]
tasks = [asyncio.create_task(description) for description in descriptions]
await asyncio.gather(*tasks)
if __name__ == "__main__":
cnt = count()
while True:
print(f"Cycle {next(cnt)}: ")
asyncio.run(main())
print()
Cycle 0:
Simulation Engineer
Python Developer
Rust Enthusiast
Cycle 1:
Rust Enthusiast
Simulation Engineer
Python Developer
Cycle 2:
Python Developer
Rust Enthusiast
Simulation Engineer
...