diff --git a/python/main.py b/python/main.py index d5619fa..da5d764 100644 --- a/python/main.py +++ b/python/main.py @@ -1,18 +1,12 @@ import asyncio import sys -async def perform_task(): - await asyncio.sleep(10) - async def main(num_tasks): - tasks = [] - - for task_id in range(num_tasks): - task = asyncio.create_task(perform_task()) - tasks.append(task) + tasks = tuple(asyncio.create_task(asyncio.sleep(10)) for _ in range(num_tasks)) + for task in tasks: + await task - await asyncio.gather(*tasks) if __name__ == "__main__": if len(sys.argv) > 1: @@ -22,4 +16,3 @@ async def main(num_tasks): asyncio.run(main(num_tasks)) print("All tasks completed") -