Last active
March 22, 2024 17:57
-
-
Save samukasmk/f0b1d9b59656537f21b6aeb085ee00b5 to your computer and use it in GitHub Desktop.
Async.IO Example #3: Run 10 async tasks waiting one by one
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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