Merge branch 'master' of git.zhangdeman.cn:zhangdeman/task
This commit is contained in:
commit
65f753208a
16
task.go
16
task.go
@ -82,8 +82,24 @@ func (d *dispatch) Run(ctx context.Context, cfg *Config) *Result {
|
||||
var (
|
||||
taskInstance ITask
|
||||
exist bool
|
||||
cancelFunc context.CancelFunc
|
||||
)
|
||||
|
||||
if nil == ctx {
|
||||
if cfg.Timeout > 0 {
|
||||
ctx, cancelFunc = context.WithCancel(context.Background())
|
||||
} else {
|
||||
ctx = context.Background()
|
||||
}
|
||||
} else {
|
||||
ctx, cancelFunc = context.WithCancel(ctx)
|
||||
}
|
||||
|
||||
if nil != cancelFunc {
|
||||
// 带了超时时间
|
||||
cancelFunc()
|
||||
}
|
||||
|
||||
result := &Result{
|
||||
StartTime: time.Now().UnixNano(),
|
||||
FinishTime: 0,
|
||||
|
Loading…
Reference in New Issue
Block a user