Back to Dagger

Execute Concurrently

docs/current_docs/partials/cookbook/builds/_execute-concurrently.mdx

0.20.71.5 KB
Original Source

Execute functions concurrently

The following Dagger Function demonstrates how to use native-language concurrency features (errgroups in Go, task groups in Python), and promises in TypeScript to execute other Dagger Functions concurrently. If any of the concurrently-running functions fails, the remaining ones will be immediately cancelled.

<Tabs groupId="language" queryString="sdk"> <TabItem value="go" label="Go">
go
</TabItem> <TabItem value="python" label="Python">
python
</TabItem> <TabItem value="typescript" label="TypeScript">
typescript
</TabItem> </Tabs>

Example

Execute a Dagger Function which performs different types of tests by executing other Dagger Functions concurrently.

<Tabs groupId="shell">
<TabItem value="System shell">
```shell
dagger -c 'my-module $(host | directory .) | run-all-tests'
```
</TabItem>
<TabItem value="Dagger Shell">
```shell title="First type 'dagger' for interactive mode."
my-module $(host | directory .) | run-all-tests
```
</TabItem>
<TabItem value="Dagger CLI">
```shell
dagger call --source=. run-all-tests
```
</TabItem>
</Tabs>