Skip to content

Instantly share code, notes, and snippets.

@samukasmk
Last active March 22, 2024 17:57
Show Gist options
  • Save samukasmk/f0b1d9b59656537f21b6aeb085ee00b5 to your computer and use it in GitHub Desktop.
Save samukasmk/f0b1d9b59656537f21b6aeb085ee00b5 to your computer and use it in GitHub Desktop.
Async.IO Example #3: Run 10 async tasks waiting one by one
import asyncio
async def create_async_results(total_items: int):
for r in range(total_items):
await asyncio.sleep(1)
yield r
async def example_of_async_for_loop():
async for item in create_async_results(10):
print(item)
asyncio.run(example_of_async_for_loop())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment