Count the peers actually tried, not the attempt counter
A job carried over from before the candidate ladder has attempts=0 while carrying a real failure in `tried`, so the summary rendered as "tried 0 peers: 1x no bytes in 20m" -- a count of zero next to the evidence contradicting it. The live instance produced exactly that when the stall check finally cleared its long-stuck job. Counts distinct usernames in `tried` instead. The two agree for anything this version enqueued; the list is the one that is right in both cases. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
39b0e0bb33
commit
c781193ec9
2 files changed
+17
-3
No files matched your search
@@ -895,13 +895,20 @@ def no_candidate_detail(seen: int, stats: "collections.Counter",
|
||||
|
||||
|
||||
def exhausted_detail(tried: list[dict], attempts: int) -> str:
|
||||
"""Summarise the whole ladder instead of overwriting it with the last error."""
|
||||
"""Summarise the whole ladder instead of overwriting it with the last error.
|
||||
|
||||
Counts `tried`, not `attempts`. They agree for anything this version
|
||||
enqueued, but a row carried over from before the ladder existed has
|
||||
attempts=0 with a real failure recorded against it, which rendered as the
|
||||
nonsense "tried 0 peers: 1x no bytes in 20m". The list is the evidence.
|
||||
"""
|
||||
if not tried:
|
||||
return "no candidate could be enqueued"
|
||||
n_peers = len({t.get("username") for t in tried if t.get("username")}) or len(tried)
|
||||
reasons = collections.Counter(t["reason"].split(":")[0] for t in tried)
|
||||
plural = "" if attempts == 1 else "s"
|
||||
plural = "" if n_peers == 1 else "s"
|
||||
joined = ", ".join(f"{n}x {r}" for r, n in reasons.most_common(3))
|
||||
return f"tried {attempts} peer{plural}: {joined}"
|
||||
return f"tried {n_peers} peer{plural}: {joined}"
|
||||
|
||||
|
||||
async def try_next_candidate(job_id: str, artist: str, title: str,
|
||||
|
||||
Reference in new issue
Block a user