Skip to content

Commit 4498e57

Browse files
committed
task: Fix context not continuous
1 parent f97054e commit 4498e57

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

common/task/task.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func (g *Group) RunContextList(contextList []context.Context) error {
6464
}
6565

6666
taskContext, taskFinish := common.ContextWithCancelCause(context.Background())
67-
taskCancelContext, taskCancel := common.ContextWithCancelCause(context.Background())
67+
taskCancelContext, taskCancel := common.ContextWithCancelCause(contextList[0])
6868

6969
var errorAccess sync.Mutex
7070
var returnError error
@@ -112,11 +112,8 @@ func (g *Group) RunContextList(contextList []context.Context) error {
112112
}()
113113
}
114114

115-
selectedContext, upstreamErr := common.SelectContext(append([]context.Context{taskCancelContext}, contextList...))
116-
117-
if selectedContext != 0 {
118-
taskCancel(upstreamErr)
119-
}
115+
selectedContext, upstreamErr := common.SelectContext(append([]context.Context{taskCancelContext}, contextList[1:]...))
116+
taskCancel(upstreamErr)
120117

121118
if g.cleanup != nil {
122119
g.cleanup()

0 commit comments

Comments
 (0)