mirror of
https://github.com/hibiken/asynq.git
synced 2024-12-25 23:32:17 +08:00
Make sure to invoke CancelFunc in all cases
This commit is contained in:
parent
1c1474c55c
commit
24f2b64c6c
10
processor.go
10
processor.go
@ -188,15 +188,17 @@ func (p *processor) exec() {
|
|||||||
<-p.sema /* release token */
|
<-p.sema /* release token */
|
||||||
}()
|
}()
|
||||||
|
|
||||||
resCh := make(chan error, 1)
|
|
||||||
task := NewTask(msg.Type, msg.Payload)
|
|
||||||
ctx, cancel := createContext(msg)
|
ctx, cancel := createContext(msg)
|
||||||
p.cancelations.Add(msg.ID.String(), cancel)
|
p.cancelations.Add(msg.ID.String(), cancel)
|
||||||
go func() {
|
defer func() {
|
||||||
resCh <- perform(ctx, task, p.handler)
|
cancel()
|
||||||
p.cancelations.Delete(msg.ID.String())
|
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 {
|
select {
|
||||||
case <-p.quit:
|
case <-p.quit:
|
||||||
// time is up, quit this worker goroutine.
|
// time is up, quit this worker goroutine.
|
||||||
|
Loading…
Reference in New Issue
Block a user