jrycw - Overview

Hi there 👋

import asyncio
import random
from itertools import count

cnt = count()
whoami = ["Simulation Engineer", "Python Developer", "Rust Enthusiast"]


async def describe(sth: str) -> None:
    await asyncio.sleep(random.random() / 10)
    print(sth)


async def _main() -> None:
    print(f"Cycle {next(cnt)}: ")
    tasks = [asyncio.create_task(describe(me)) for me in whoami]
    await asyncio.gather(*tasks)
    print()


async def main() -> None:
    while True:
        await _main()


if __name__ == "__main__":
    asyncio.run(main())
Cycle 0:
Simulation Engineer
Python Developer
Rust Enthusiast

Cycle 1:
Rust Enthusiast
Simulation Engineer
Python Developer

Cycle 2:
Python Developer
Rust Enthusiast
Simulation Engineer
...