#Structured concurrency

1 messages · Page 1 of 1 (latest)

odd orbit
#

Hey @supple bolt!

No, that'll wait for tflint first and then do fmt. What you want is a Task Group:

class Test:
  @function
  async def check(self, source: dagger.Directory) -> str:
      result = []
  
      async def get_output(ctr: dagger.Container):
          result.append(await ctr.stdout())
  
      async with anyio.create_task_group() as tg:
          tg.start_soon(get_output, self.tflint(source))
          tg.start_soon(get_output, self.fmt_check(source))
  
      return "\n".join(result)

There’s also a simpler and more lazy way that leverages the query itself:

class Test:
  @function
  def check(self, source: dagger.Directory) -> list[dagger.Container]:
      result [
          self.tflint(source),
          self.fmt_check(source),
      ]

In the CLI, you just add stdout which will add to each item in the list and present the results:

❯ dagger call check --source=. stdout

More on: