From 46b6abf7df2b9876afee4de1c3f41aa931b80dfb Mon Sep 17 00:00:00 2001 From: Ronen Hilewicz Date: Mon, 6 Jan 2025 08:54:46 -0500 Subject: [PATCH] Fix panic in Jobpool.Wait() --- jobpool/jobpool.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/jobpool/jobpool.go b/jobpool/jobpool.go index 7ac86cd..cc6a207 100644 --- a/jobpool/jobpool.go +++ b/jobpool/jobpool.go @@ -83,12 +83,10 @@ func (jp *JobPool[IN, OUT]) Start() { // Results are returned in the order that jobs were produced. func (jp *JobPool[IN, OUT]) Wait() []OUT { close(jp.inbox) - go func() { - jp.wg.Wait() - close(jp.outbox) - }() + jp.wg.Wait() + close(jp.outbox) - results := make([]OUT, len(jp.inbox)) + results := make([]OUT, len(jp.outbox)) for result := range jp.outbox { results[result.index] = result.result }