MCPcopy Index your code
hub / github.com/docker/docker-agent / startToolsetWithTimeout

Function startToolsetWithTimeout

pkg/runtime/runtime.go:1722–1740  ·  view source on GitHub ↗

startToolsetWithTimeout starts a toolset under a bounded deadline, mirroring listToolsWithTimeout. The deadline must be enforced by racing the call against the timeout (not only via the context): the MCP connector detaches the context it is handed with context.WithoutCancel, so a wedged initialize h

(ctx context.Context, toolset *tools.StartableToolSet, timeout time.Duration)

Source from the content-addressed store, hash-verified

1720// becomes usable on the next turn; if it never does, the TUI shutdown safety
1721// net still bounds the exit path.
1722func startToolsetWithTimeout(ctx context.Context, toolset *tools.StartableToolSet, timeout time.Duration) error {
1723 if timeout <= 0 {
1724 timeout = defaultToolStartTimeout
1725 }
1726 startCtx, cancel := context.WithTimeout(ctx, timeout)
1727 defer cancel()
1728
1729 done := make(chan error, 1) // buffered so a late send never blocks
1730 go func() {
1731 done <- toolset.Start(startCtx)
1732 }()
1733
1734 select {
1735 case <-startCtx.Done():
1736 return startCtx.Err()
1737 case err := <-done:
1738 return err
1739 }
1740}
1741
1742func (r *LocalRuntime) Resume(_ context.Context, req ResumeRequest) {
1743 slog.Debug("Resuming runtime", "agent", r.currentAgentName(), "type", req.Type, "reason", req.Reason)

Callers 1

Calls 2

StartMethod · 0.65
ErrMethod · 0.65

Tested by

no test coverage detected