Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,18 +91,19 @@ func (s *jobScheduler) Schedule() {
continue
}

select {
case <-s.cancel:
return
case <-time.After(s.backoff.Duration()):
}
}

if ErrJobSource.Is(err) {
close(s.jobs)
return
}

select {
case <-s.cancel:
return
case <-time.After(s.backoff.Duration()):
}

continue
}

Expand Down
6 changes: 1 addition & 5 deletions worker_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,8 @@ func (wp *WorkerPool) remove(n int) {
wg.Wait()
}

// Wait waits for the workers to finish. A worker will finish when the queue to
// retrieve jobs from is closed.
// Wait waits for the workers to finish.
func (wp *WorkerPool) Wait() {
<-wp.resize
defer func() { wp.resize <- struct{}{} }()

wp.wg.Wait()
wp.workers = nil
wp.opts.Metrics.Stop(false)
Expand Down