wirehead: watermark advances only past actually-answered ids; log worker misses
This commit is contained in:
1 parent
e356abac9f
commit
6b193a4adb
1 file changed
+7
-3
@@ -311,6 +311,7 @@ def poll_once():
|
|||||||
if new:
|
if new:
|
||||||
log("new mentions:", len(new))
|
log("new mentions:", len(new))
|
||||||
replied = 0
|
replied = 0
|
||||||
|
answered_ids = []
|
||||||
for p in new:
|
for p in new:
|
||||||
if st["used"] >= DAILY_BUDGET or replied >= PER_POLL_CAP:
|
if st["used"] >= DAILY_BUDGET or replied >= PER_POLL_CAP:
|
||||||
break
|
break
|
||||||
@@ -326,12 +327,14 @@ def poll_once():
|
|||||||
log("signal:", desc)
|
log("signal:", desc)
|
||||||
out = run_job(text, valence, dose, mix, desc, topic)
|
out = run_job(text, valence, dose, mix, desc, topic)
|
||||||
if not out:
|
if not out:
|
||||||
|
log("worker returned nothing for", mid, "- will retry next poll")
|
||||||
continue
|
continue
|
||||||
kind = "mix" if mix else (topic or valence)
|
kind = "mix" if mix else (topic or valence)
|
||||||
reply = f"[{kind}{dose}x-{TAG}] {out.strip()}"
|
reply = f"[{kind}{dose}x-{TAG}] {out.strip()}"
|
||||||
reply = trim_tweet(reply)
|
reply = trim_tweet(reply)
|
||||||
if post_reply(mid, reply):
|
if post_reply(mid, reply):
|
||||||
replied += 1
|
replied += 1
|
||||||
|
answered_ids.append(mid)
|
||||||
st["used"] += 1
|
st["used"] += 1
|
||||||
log("replied:", replied, "/", st["used"], "today")
|
log("replied:", replied, "/", st["used"], "today")
|
||||||
time.sleep(3)
|
time.sleep(3)
|
||||||
@@ -340,9 +343,10 @@ def poll_once():
|
|||||||
# unanswered backlog permanently (observed 2026-10-01: 3 backlog
|
# unanswered backlog permanently (observed 2026-10-01: 3 backlog
|
||||||
# mentions lost because last_id jumped to the newest fetched id)
|
# mentions lost because last_id jumped to the newest fetched id)
|
||||||
if posts and replied > 0:
|
if posts and replied > 0:
|
||||||
answered_max = max(p.get("id", "0") for p in new[:replied])
|
if answered_ids:
|
||||||
st["last_id"] = max(st["last_id"], answered_max)
|
answered_max = max(answered_ids)
|
||||||
save_state(st)
|
st["last_id"] = max(st["last_id"], answered_max)
|
||||||
|
save_state(st)
|
||||||
log("poll done; used %d/%d today" % (st["used"], DAILY_BUDGET))
|
log("poll done; used %d/%d today" % (st["used"], DAILY_BUDGET))
|
||||||
return POLL_SECS
|
return POLL_SECS
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user