Skip to content

Instantly share code, notes, and snippets.

@jordanorelli
Created July 31, 2026 14:36
Show Gist options
  • Select an option

  • Save jordanorelli/96be563fad4cd08af2ed17a239c149a3 to your computer and use it in GitHub Desktop.

Select an option

Save jordanorelli/96be563fad4cd08af2ed17a239c149a3 to your computer and use it in GitHub Desktop.
asyncio scheduler contention
import asyncio
import time
async def badguy():
# await asyncio.sleep(0.001) # 1ms
time.sleep(0.499) # 499ms
async def goodguy():
start = time.perf_counter()
await asyncio.sleep(0.01) # 10ms
elapsed = time.perf_counter() - start
print(f"goodguy took {elapsed}")
async def main():
await asyncio.gather(badguy(), goodguy())
await asyncio.gather(goodguy(), badguy())
asyncio.run(main())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment