diff --git a/common/task/task.go b/common/task/task.go index 958f3a4..cbddb7a 100644 --- a/common/task/task.go +++ b/common/task/task.go @@ -64,7 +64,7 @@ func (g *Group) RunContextList(contextList []context.Context) error { } taskContext, taskFinish := common.ContextWithCancelCause(context.Background()) - taskCancelContext, taskCancel := common.ContextWithCancelCause(context.Background()) + taskCancelContext, taskCancel := common.ContextWithCancelCause(contextList[0]) var errorAccess sync.Mutex var returnError error @@ -112,11 +112,8 @@ func (g *Group) RunContextList(contextList []context.Context) error { }() } - selectedContext, upstreamErr := common.SelectContext(append([]context.Context{taskCancelContext}, contextList...)) - - if selectedContext != 0 { - taskCancel(upstreamErr) - } + selectedContext, upstreamErr := common.SelectContext(append([]context.Context{taskCancelContext}, contextList[1:]...)) + taskCancel(upstreamErr) if g.cleanup != nil { g.cleanup()