Skip to content

Commit

Permalink
task: Fix context not continuous
Browse files Browse the repository at this point in the history
  • Loading branch information
nekohasekai committed Jul 31, 2024
1 parent f97054e commit 4498e57
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions common/task/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 4498e57

Please sign in to comment.