Created
October 19, 2023 20:35
-
-
Save phalt/f03371554bec632687e37cefa7b90b32 to your computer and use it in GitHub Desktop.
Run async functions together and return them
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 gather_functions(funcs): | |
tasks = [asyncio.create_task(f) for f in funcs] | |
return await asyncio.gather(*tasks) | |
def run(funcs): | |
""" | |
Run a list of async functions and return the results. | |
""" | |
return asyncio.run(gather_functions(funcs)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment