Skip to content

Instantly share code, notes, and snippets.

@johnslavik
Last active February 16, 2026 15:37
Show Gist options
  • Select an option

  • Save johnslavik/77e689c043276612d2e9286df318243c to your computer and use it in GitHub Desktop.

Select an option

Save johnslavik/77e689c043276612d2e9286df318243c to your computer and use it in GitHub Desktop.
import asyncio
import os
async def task_inner():
with open("/dev/urandom", "rb") as urandom:
feed = await asyncio.to_thread(urandom.read, 128)
print(feed[:16].hex(), "\r", end="")
async def task():
async with asyncio.TaskGroup() as tg:
tg.create_task(task_inner())
async def main():
while True:
await task()
if __name__ == "__main__":
print(f"PID: {os.getpid()}")
asyncio.run(main())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment