Skip to content

Commit

Permalink
Use TaskGroups
Browse files Browse the repository at this point in the history
  • Loading branch information
itamaro committed May 3, 2023
1 parent 00db076 commit fe365c8
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,12 @@ async def recurse(self, recurse_level):
await self.workload_func()
return

await asyncio.gather(
*[self.recurse(recurse_level - 1) for _ in range(NUM_RECURSE_BRANCHES)]
)
# await asyncio.gather(
# *[self.recurse(recurse_level - 1) for _ in range(NUM_RECURSE_BRANCHES)]
# )
async with asyncio.TaskGroup() as tg:
for _ in range(NUM_RECURSE_BRANCHES):
tg.create_task(self.recurse(recurse_level - 1))

async def run(self):
await self.recurse(NUM_RECURSE_LEVELS)
Expand Down

0 comments on commit fe365c8

Please sign in to comment.