Skip to content

Commit

Permalink
Stop workers before requeuing their jobs (#22)
Browse files Browse the repository at this point in the history
When the node is closed.
  • Loading branch information
raphael authored Oct 10, 2024
1 parent 29a0795 commit e3f9b34
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion pool/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,9 +357,19 @@ func (node *Node) Close(ctx context.Context) error {
}
node.logger.Info("closing")
node.closing = true

// Need to stop workers before requeueing jobs to prevent
// requeued jobs from being handled by this node.
var wg sync.WaitGroup
for _, w := range node.localWorkers {
go w.stopAndWait(ctx)
wg.Add(1)
go func(w *Worker) {
defer wg.Done()
w.stopAndWait(ctx)
}(w)
}
wg.Wait()

for _, w := range node.localWorkers {
w.requeueJobs(ctx)
}
Expand Down

0 comments on commit e3f9b34

Please # to comment.