From 7295c16367162331b4f13c7fa7e82404d3781416 Mon Sep 17 00:00:00 2001 From: gazebo Date: Fri, 21 Sep 2018 16:57:34 +0800 Subject: [PATCH] - miss use err: in SyncSku --- business/jxstore/cms/sync.go | 3 ++- business/jxutils/tasksch/task.go | 7 +++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/business/jxstore/cms/sync.go b/business/jxstore/cms/sync.go index 6d25431f1..b95a0837c 100644 --- a/business/jxstore/cms/sync.go +++ b/business/jxstore/cms/sync.go @@ -106,7 +106,8 @@ func (v *VendorSync) SyncSku(db *dao.DaoDB, nameID, skuID int, isForce bool, use if skuID != -1 { cond[model.FieldID] = skuID } - if err := dao.GetEntitiesByKV(db, &skuList, cond, true); err == nil { + err := dao.GetEntitiesByKV(db, &skuList, cond, true) + if err == nil { globals.SugarLogger.Debug(utils.Format4Output(skuList, false)) task := tasksch.RunTask("SyncSku", func(batchItemList []interface{}, params ...interface{}) (interface{}, error) { sku := batchItemList[0].(*model.Sku) diff --git a/business/jxutils/tasksch/task.go b/business/jxutils/tasksch/task.go index 6fce9b8e1..ce9d20d23 100644 --- a/business/jxutils/tasksch/task.go +++ b/business/jxutils/tasksch/task.go @@ -125,7 +125,9 @@ func RunTask(taskName string, worker WorkFunc, resultHandler ResultHandlerFunc, } end: // globals.SugarLogger.Debugf("RunTask %s, put to chann chanRetVal:%v", taskName, chanRetVal) - task.subFinishChan <- chanRetVal + if task.GetStatus() < TaskStatusEndBegin { + task.subFinishChan <- chanRetVal + } }() } for _, job := range jobList { @@ -142,6 +144,7 @@ func RunTask(taskName string, worker WorkFunc, resultHandler ResultHandlerFunc, if err2, ok := result.(error); ok { taskResult = nil taskErr = err2 + break } else if result != nil { resultList := result.([]interface{}) taskResult = append(taskResult, resultList...) @@ -162,8 +165,8 @@ func RunTask(taskName string, worker WorkFunc, resultHandler ResultHandlerFunc, task.err = taskErr task.result = taskResult task.TerminatedAt = time.Now() - task.locker.Unlock() + globals.SugarLogger.Debugf("RunTask %s, result:%v, err:%v", taskName, taskResult, taskErr) close(task.finishChan)