diff --git a/worker.go b/worker.go index 15e4651..22965fb 100644 --- a/worker.go +++ b/worker.go @@ -31,6 +31,8 @@ func worker(context context.Context, waitGroup *sync.WaitGroup, firstTask func() // We have received a task, ignore it taskWaitGroup.Done() } + // Pool context was cancelled, empty tasks channel and exit + drainTasks(tasks, taskWaitGroup) return default: if task == nil || !ok {