Skip to content

Commit

Permalink
Merge pull request #71 from hongkuancn/context-done
Browse files Browse the repository at this point in the history
Fix bug that worker doesn't return after context cancel
  • Loading branch information
alitto committed Sep 1, 2024
2 parents 5f162d4 + 1b21aaa commit a64a339
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ 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 {
// We have received a signal to exit
Expand Down

0 comments on commit a64a339

Please sign in to comment.