mirror of
https://github.com/hibiken/asynq.git
synced 2024-11-10 11:31:58 +08:00
Fix bug around releasing semaphore token
This commit is contained in:
parent
c6f482d4f8
commit
3daef02632
4
asynq.go
4
asynq.go
@ -154,9 +154,10 @@ func (w *Workers) Run(handler TaskHandler) {
|
||||
log.Printf("[Servere Error] could not parse json encoded message %s: %v", data, err)
|
||||
continue
|
||||
}
|
||||
w.poolTokens <- struct{}{} // acquire a token
|
||||
t := &Task{Type: msg.Type, Payload: msg.Payload}
|
||||
w.poolTokens <- struct{}{} // acquire token
|
||||
go func(task *Task) {
|
||||
defer func() { <-w.poolTokens }() // release token
|
||||
err := handler(task)
|
||||
if err != nil {
|
||||
if msg.Retried >= msg.Retry {
|
||||
@ -178,7 +179,6 @@ func (w *Workers) Run(handler TaskHandler) {
|
||||
}
|
||||
|
||||
}
|
||||
<-w.poolTokens // release the token
|
||||
}(t)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user