From af043b7f5b90739d00e89f6686a4d871392d0741 Mon Sep 17 00:00:00 2001 From: Subir Adhikari <41926114+mistu4u@users.noreply.github.com> Date: Mon, 17 Oct 2022 20:00:28 +0530 Subject: [PATCH] fix for high cpu usage (#386) * fix for high cpu usage * Update go_test.yml * Update file_formatting.yml * revert file_formatting.yml to original * newline Co-authored-by: John Roesler --- executor.go | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/executor.go b/executor.go index e9aafd57..9a9cd220 100644 --- a/executor.go +++ b/executor.go @@ -67,18 +67,17 @@ func (e *executor) start() { case RescheduleMode: return case WaitMode: - for { - select { - case <-stopCtx.Done(): - return - case <-f.ctx.Done(): - return - default: - } - - if e.maxRunningJobs.TryAcquire(1) { - break - } + select { + case <-stopCtx.Done(): + return + case <-f.ctx.Done(): + return + default: + } + + if err := e.maxRunningJobs.Acquire(f.ctx, 1); err != nil { + break + } } }