Background compiles give way to the lander: the Logbook statistics and the results refresher wait while [logbook] lander_lock is fresh (under 60 min); the statistics tools run below normal priority and a timeout ends the whole tree (an orphaned cl.exe went on compiling main at normal priority); a retried statistics run no longer relogs the same commits

This commit is contained in:
KeelrLeek committed 2026-10-09 10:46:40 -05:00
1 parent 21b7fedb6f
commit 56308e3aab
5 files changed
+154 -14

No files matched your search

+18 -5
View File
@@ -9,6 +9,8 @@ Configured per project in a [logbook] table:
decomp = 'R:/.../open-seas-decomp' the repository whose main branch is followed
stats_repo = 'R:/.../stats-work/repo' a scratch copy of open-seas holding tools/progress/*.py
interval_minutes = 10 how often the server looks (default 10)
lander_lock = 'R:/.../lander-busy.lock' wait while the lander runs its gates (harbor.lander_gate)
The progress tools run below normal priority.
Milestones and narrative entries stay with people: they need judgement.
State (the last commit seen) is kept in the logbook folder as auto.json."""
@@ -22,9 +24,10 @@ import time
import traceback
from pathlib import Path
from . import logbook
from . import lander_gate, logbook
MAX_ENTRIES = 25
STATS_TIMEOUT = 1800 # each progress tool; sync_decomp compiles every readable file, below normal priority
def _git(repo, *args):
@@ -88,8 +91,10 @@ def rebuild_stats(project, repo, stats_repo, head):
installer = r"C:\Program Files (x86)\Microsoft Visual Studio\Installer"
if os.path.isdir(installer) and installer.lower() not in env.get("PATH", "").lower():
env["PATH"] = installer + os.pathsep + env.get("PATH", "")
run = lambda *argv: subprocess.run([sys.executable, "-B", *map(str, argv)], cwd=str(stats_repo), env=env,
capture_output=True, text=True, encoding="utf-8", errors="replace", timeout=900)
# below normal priority (cl.exe inherits it), so the lander's and the agents' compiles go first; a timeout ends
# the whole tree, not only python (an orphaned cl.exe went on compiling all of main at normal priority)
run = lambda *argv: lander_gate.run_low([sys.executable, "-B", *map(str, argv)], STATS_TIMEOUT,
cwd=str(stats_repo), env=env, encoding="utf-8", errors="replace")
sync = run(tools / "sync_decomp.py", "--decomp", repo)
if sync.returncode != 0:
raise RuntimeError("sync_decomp: " + (sync.stdout + sync.stderr).strip()[-400:])
@@ -134,12 +139,20 @@ def refresh(project, force=False):
state = _state(project)
if state.get("last_head") == head and not force:
return {"changed": False, "head": head[:8]}
busy = None if force else lander_gate.lander_busy(project)
if busy: # its gates compile all of main: look again next time
return {"changed": False, "head": head[:8], "waiting": busy}
out = {"changed": True, "head": head[:8]}
if state.get("last_head"):
# last_head is where the statistics are; logged_head where the ship's log is (a failed statistics run is retried,
# and must not log the same commits twice)
logged = state.get("logged_head") or state.get("last_head")
if logged and logged != head:
try:
out["entries"] = len(log_commits(project, repo, state["last_head"], head))
out["entries"] = len(log_commits(project, repo, logged, head))
except RuntimeError as error: # e.g. the old commit vanished after a rewrite
out["log_error"] = str(error)
if logged:
state["logged_head"] = head
if stats_repo:
try:
out["stats"] = rebuild_stats(project, snapshot_at(config, repo, head), stats_repo, head)