2
0
mirror of https://github.com/hibiken/asynq.git synced 2026-08-25 08:44:32 +08:00

Update log messages on shutdown

This commit is contained in:
Ken Hibino
2019-11-27 06:33:04 -08:00
parent 60132f3208
commit e6b1230c36
3 changed files with 8 additions and 8 deletions

View File

@@ -29,15 +29,16 @@ func newProcessor(rdb *rdb, numWorkers int, handler TaskHandler) *processor {
}
func (p *processor) terminate() {
fmt.Print("Processor shutting down...")
// Signal the processor goroutine to stop processing tasks from the queue.
p.done <- struct{}{}
fmt.Println("--- Waiting for all workers to finish ---")
fmt.Print("Waiting for all workers to finish...")
for i := 0; i < cap(p.sema); i++ {
// block until all workers have released the token
p.sema <- struct{}{}
}
fmt.Println("--- All workers have finished! ----")
fmt.Println("Done")
}
func (p *processor) start() {
@@ -48,9 +49,7 @@ func (p *processor) start() {
for {
select {
case <-p.done:
fmt.Println("-------------[Processor]---------------")
fmt.Println("Processor shutting down...")
fmt.Println("-------------------------------------")
fmt.Println("Done")
return
default:
p.exec()