Created
December 11, 2022 20:35
-
-
Save hclivess/c8e766f442b37718341b786c38e68a58 to your computer and use it in GitHub Desktop.
Simple asynchronous gather function
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 | |
pets = ["aliens", "cats", "dogs", "ostriches"] | |
def print_pet(pet): | |
print(pet) | |
async def main(): | |
await asyncio.gather(print_pet(pet) for pet in pets) | |
asyncio.run(main()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment