MCPcopy Create free account
hub / github.com/diillson/chatcli / waitForTerminal

Function waitForTerminal

cli/scheduler_command.go:634–653  ·  view source on GitHub ↗

waitForTerminal polls the remote client until the job reaches a terminal state or ctx is cancelled.

(ctx context.Context, c *scheduler.RemoteClient, id scheduler.JobID)

Source from the content-addressed store, hash-verified

632// waitForTerminal polls the remote client until the job reaches a
633// terminal state or ctx is cancelled.
634func waitForTerminal(ctx context.Context, c *scheduler.RemoteClient, id scheduler.JobID) {
635 t := time.NewTicker(500 * time.Millisecond)
636 defer t.Stop()
637 for {
638 select {
639 case <-ctx.Done():
640 fmt.Println(colorize(" ⚠ "+i18n.T("scheduler.wait_ctx_cancelled"), ColorYellow))
641 return
642 case <-t.C:
643 j, err := c.Query(ctx, id)
644 if err != nil {
645 continue
646 }
647 if j.Status.IsTerminal() {
648 fmt.Println(colorize(fmt.Sprintf(" ✔ job %s → %s", id, j.Status), ColorGreen))
649 return
650 }
651 }
652 }
653}
654
655// ─── Argument parsers ─────────────────────────────────────────
656

Callers 1

handleWaitCommandMethod · 0.85

Calls 5

TFunction · 0.92
colorizeFunction · 0.85
StopMethod · 0.65
QueryMethod · 0.45
IsTerminalMethod · 0.45

Tested by

no test coverage detected