}
arv.Retries = 25
- disp.slurm = &slurmCLI{}
+ disp.slurm = NewSlurmCLI()
disp.sqCheck = &SqueueChecker{
Period: time.Duration(disp.PollPeriod),
PrioritySpread: disp.PrioritySpread,
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)
}
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()