2
0
mirror of https://github.com/hibiken/asynq.git synced 2024-09-20 02:55:54 +08:00

Make sure to invoke CancelFunc in all cases

This commit is contained in:
Ken Hibino 2020-05-03 13:58:54 -07:00
parent 1c1474c55c
commit 24f2b64c6c

View File

@ -188,15 +188,17 @@ func (p *processor) exec() {
<-p.sema /* release token */
}()
resCh := make(chan error, 1)
task := NewTask(msg.Type, msg.Payload)
ctx, cancel := createContext(msg)
p.cancelations.Add(msg.ID.String(), cancel)
go func() {
resCh <- perform(ctx, task, p.handler)
defer func() {
cancel()
p.cancelations.Delete(msg.ID.String())
}()
resCh := make(chan error, 1)
task := NewTask(msg.Type, msg.Payload)
go func() { resCh <- perform(ctx, task, p.handler) }()
select {
case <-p.quit:
// time is up, quit this worker goroutine.