# Created on savesnippets.com · https://savesnippets.com/1scEleKFQzhauX import asyncio import time import hashlib def cpu_heavy(n: int) -> str: """Blocking — would freeze the event loop if called directly.""" h = hashlib.sha256(b"seed").digest() for _ in range(n): h = hashlib.sha256(h).digest() return h.hex() async def main(): # Three CPU-heavy calls in parallel without blocking the loop results = await asyncio.gather( asyncio.to_thread(cpu_heavy, 100_000), asyncio.to_thread(cpu_heavy, 100_000), asyncio.to_thread(cpu_heavy, 100_000), ) print([r[:8] for r in results]) asyncio.run(main())