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)
| 632 | // waitForTerminal polls the remote client until the job reaches a |
| 633 | // terminal state or ctx is cancelled. |
| 634 | func 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 |
no test coverage detected