- optimize tasksch channel.
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, 1)
|
||||
t.finishChan = make(chan int, 1)
|
||||
t.quitChan = make(chan int)
|
||||
t.finishChan = make(chan int)
|
||||
t.Status = TaskStatusWorking
|
||||
|
||||
t.C = t.finishChan
|
||||
@@ -228,11 +228,17 @@ func (t *BaseTask) run(taskHandler func()) {
|
||||
}()
|
||||
|
||||
taskHandler()
|
||||
select {
|
||||
case <-t.quitChan:
|
||||
default:
|
||||
close(t.quitChan)
|
||||
}
|
||||
for _, subTask := range t.Children {
|
||||
if _, err := subTask.GetResult(0); err != nil {
|
||||
globals.SugarLogger.Warnf("BaseTask run, failed with error:%v", err)
|
||||
}
|
||||
}
|
||||
close(t.finishChan)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user