- close quitChan when Cancel for tasksch.
This commit is contained in:
@@ -101,8 +101,8 @@ func (t *BaseTask) Init(parallelCount, batchSize int, isContinueWhenError bool,
|
||||
t.TerminatedAt = utils.DefaultTimeValue
|
||||
t.TotalItemCount = totalItemCount
|
||||
t.TotalJobCount = totalJobCount
|
||||
t.quitChan = make(chan int, parallelCount)
|
||||
t.finishChan = make(chan int, 2)
|
||||
t.quitChan = make(chan int, 1)
|
||||
t.finishChan = make(chan int, 1)
|
||||
t.Status = TaskStatusWorking
|
||||
|
||||
t.C = t.finishChan
|
||||
@@ -143,9 +143,7 @@ func (t *BaseTask) Cancel() {
|
||||
t.locker.Lock()
|
||||
if t.Status < TaskStatusEndBegin && t.Status != TaskStatusCanceling {
|
||||
t.Status = TaskStatusCanceling
|
||||
for i := 0; i < t.ParallelCount; i++ {
|
||||
t.quitChan <- 0
|
||||
}
|
||||
close(t.quitChan)
|
||||
}
|
||||
t.locker.Unlock()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user