X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/53ce9b61336c5385eb2250267efa69613b5eaec7..cb690390d4f253c3bbb9c543e243cf988f39fbb3:/services/crunch-dispatch-slurm/slurm.go diff --git a/services/crunch-dispatch-slurm/slurm.go b/services/crunch-dispatch-slurm/slurm.go index 9e9f45270f..e59826f763 100644 --- a/services/crunch-dispatch-slurm/slurm.go +++ b/services/crunch-dispatch-slurm/slurm.go @@ -2,7 +2,7 @@ // // SPDX-License-Identifier: AGPL-3.0 -package main +package dispatchslurm import ( "fmt" @@ -20,7 +20,15 @@ type Slurm interface { Renice(name string, nice int64) error } -type slurmCLI struct{} +type slurmCLI struct { + runSemaphore chan bool +} + +func NewSlurmCLI() *slurmCLI { + return &slurmCLI{ + runSemaphore: make(chan bool, 3), + } +} func (scli *slurmCLI) Batch(script io.Reader, args []string) error { return scli.run(script, "sbatch", args) @@ -64,6 +72,8 @@ func (scli *slurmCLI) Renice(name string, nice int64) error { } func (scli *slurmCLI) run(stdin io.Reader, prog string, args []string) error { + scli.runSemaphore <- true + defer func() { <-scli.runSemaphore }() cmd := exec.Command(prog, args...) cmd.Stdin = stdin out, err := cmd.CombinedOutput()