fix: Workmanager delayTaskWithoutReqctx

The context of delayTaskWithoutReqctx should have 'taskid' value.
This commit is contained in:
Rain
2020-01-06 11:29:12 +08:00
parent ef1ad52bae
commit 02d2c69d39
+6 -2
View File
@@ -111,8 +111,12 @@ func (w *SWorkManager) DelayTaskWithoutReqctx(ctx context.Context, task DelayTas
func (w *SWorkManager) delayTaskWithoutReqctx(
ctx context.Context, task DelayTaskFunc, params interface{}, worker *appsrv.SWorkerManager,
) {
// delayTaskWithReqctx should have a new context.Context
ctx = context.Background()
// delayTaskWithoutReqctx should have a new context.Context
newCtx := context.Background()
if ctx != nil && ctx.Value(appctx.APP_CONTEXT_KEY_TASK_ID) != nil {
newCtx = context.WithValue(newCtx, appctx.APP_CONTEXT_KEY_TASK_ID, ctx.Value(appctx.APP_CONTEXT_KEY_TASK_ID))
}
ctx = newCtx
w.add()
w.worker.Run(func() {
defer w.done()