MCPcopy
hub / github.com/go-task/task / startExecution

Method startExecution

task.go:440–471  ·  view source on GitHub ↗
(ctx context.Context, t *ast.Task, execute func(ctx context.Context) error)

Source from the content-addressed store, hash-verified

438}
439
440func (e *Executor) startExecution(ctx context.Context, t *ast.Task, execute func(ctx context.Context) error) error {
441 h, err := e.GetHash(t)
442 if err != nil {
443 return err
444 }
445
446 if h == "" || t.Watch {
447 return execute(ctx)
448 }
449
450 e.executionHashesMutex.Lock()
451
452 if otherExecutionCtx, ok := e.executionHashes[h]; ok {
453 e.executionHashesMutex.Unlock()
454 e.Logger.VerboseErrf(logger.Magenta, "task: skipping execution of task: %s\n", h)
455
456 // Release our execution slot to avoid blocking other tasks while we wait
457 reacquire := e.releaseConcurrencyLimit()
458 defer reacquire()
459
460 <-otherExecutionCtx.Done()
461 return nil
462 }
463
464 ctx, cancel := context.WithCancel(ctx)
465 defer cancel()
466
467 e.executionHashes[h] = ctx
468 e.executionHashesMutex.Unlock()
469
470 return execute(ctx)
471}
472
473// FindMatchingTasks returns a list of tasks that match the given call. A task
474// matches a call if its name is equal to the call's task name, or one of aliases, or if it matches

Callers 1

RunTaskMethod · 0.95

Calls 3

GetHashMethod · 0.95
VerboseErrfMethod · 0.80

Tested by

no test coverage detected