MCPcopy Create free account
hub / github.com/compozy/agh / waitAndForceStopRun

Method waitAndForceStopRun

internal/task/manager.go:3562–3577  ·  view source on GitHub ↗
(ctx context.Context, sessionID string, reason StopReason)

Source from the content-addressed store, hash-verified

3560}
3561
3562func (m *Service) waitAndForceStopRun(ctx context.Context, sessionID string, reason StopReason) error {
3563 if m.cancelGracePeriod > 0 {
3564 timer := time.NewTimer(m.cancelGracePeriod)
3565 defer timer.Stop()
3566
3567 select {
3568 case <-timer.C:
3569 case <-ctx.Done():
3570 return fmt.Errorf("task: wait for force-stop grace period on session %q: %w", sessionID, ctx.Err())
3571 }
3572 }
3573 if err := m.sessions.ForceTaskStop(ctx, sessionID, reason); err != nil {
3574 return fmt.Errorf("task: force stop session %q: %w", sessionID, err)
3575 }
3576 return nil
3577}
3578
3579func recoverySessionStateRequiresCooperativeStop(state string) bool {
3580 switch strings.TrimSpace(state) {

Callers 3

cancelRunRecordMethod · 0.95

Calls 4

StopMethod · 0.65
DoneMethod · 0.65
ForceTaskStopMethod · 0.65
ErrMethod · 0.45

Tested by 1