2
0
mirror of https://github.com/hibiken/asynq.git synced 2026-08-21 11:24:21 +08:00

Minor cleanup

This commit is contained in:
Ken Hibino
2019-11-27 19:36:56 -08:00
parent 0db4b8a34f
commit c9a8f5fabd
3 changed files with 13 additions and 18 deletions

View File

@@ -34,8 +34,8 @@ func (p *processor) terminate() {
p.done <- struct{}{}
fmt.Print("Waiting for all workers to finish...")
// block until all workers have released the token
for i := 0; i < cap(p.sema); i++ {
// block until all workers have released the token
p.sema <- struct{}{}
}
fmt.Println("Done")
@@ -65,18 +65,13 @@ func (p *processor) exec() {
// in case of a program shutdown or additon of a new queue.
const timeout = 5 * time.Second
msg, err := p.rdb.dequeue(defaultQueue, timeout)
if err == errDequeueTimeout {
// timed out, this is a normal behavior.
return
}
if err != nil {
switch err {
case errQueuePopTimeout:
// timed out, this is a normal behavior.
return
case errDeserializeTask:
log.Println("[Error] could not parse json encoded message")
return
default:
log.Printf("[Error] unexpected error while pulling message out of queues: %v\n", err)
return
}
log.Printf("[ERROR] unexpected error while pulling a task out of queue: %v\n", err)
return
}
task := &Task{Type: msg.Type, Payload: msg.Payload}