Skip to content

Instantly share code, notes, and snippets.

@hclivess
Created December 11, 2022 20:35
Show Gist options
  • Save hclivess/c8e766f442b37718341b786c38e68a58 to your computer and use it in GitHub Desktop.
Save hclivess/c8e766f442b37718341b786c38e68a58 to your computer and use it in GitHub Desktop.
Simple asynchronous gather function
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