Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/nuauto/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ def start(self, kind, label, cmd, browser=True, background=False, env=None, on_d
f"pid {holder.get('pid')}). Try again when it is done.")
scr = run_screen(kind) if watch and REMOTE and not config.DEMO else None
task = Task(kind, label, cmd, browser, background, env, on_done=self._done(on_done),
on_row=None if background else self.refresh_soon, screen=scr)
on_row=None if background else self.refresh_after_row, screen=scr)
if background:
self.background = task
else:
Expand Down Expand Up @@ -282,6 +282,11 @@ def refresh_rows(self, force=False):
if force or self.rows is None or now() - self.rows_at >= 60:
self.run_group("sheet")

def refresh_after_row(self):
"""A row just finished in a run: read the sheet again for sure (refresh_soon skips while another read is under
way, which would leave the finished row's buttons on the Apply screen until the next read)."""
threading.Thread(target=self.refresh_rows, kwargs={"force": True}, daemon=True).start()

def refresh_soon(self, max_age=0):
"""Read the sheet again in the background when the rows are older than max_age seconds, so the lists and counts
follow changes made elsewhere (a row finished in a run, an assistant in a terminal, the sheet itself). A failed
Expand Down
2 changes: 2 additions & 0 deletions src/nuauto/gui_static/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,9 @@ async function pollTask() {
if (t) {
S.taskLog.push(...t.log);
S.taskAfter = t.log_total;
const doneBefore = S.task && S.task.id === t.id ? S.task.done_rows.length : 0;
S.task = t;
if (t.done_rows.length > doneBefore) setTimeout(pollState, 1500); // a row finished: the lists read the sheet again now
const was = S.lastTaskState[t.id];
S.lastTaskState[t.id] = t.state;
if (was === "running" && t.state !== "running") taskFinished(t);
Expand Down
Loading