fix(scheduler): trumpstruth poller never fires — APScheduler bug
next_run_time=None means "paused", not "default". The fallback poller was registered but never triggered, leaving the system on CNN archive only. Set explicit start time = now + half the poll interval so the two pollers offset and don't hit upstream simultaneously. Verified via /api/health/deep: trumpstruth.last_poll was null on the live server before this fix despite the poller having been deployed. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
+6
-1
@@ -69,6 +69,11 @@ async def lifespan(app: FastAPI):
|
||||
# same external_id hash, so dedup is automatic. Whoever sees the post
|
||||
# first wins. Offset by half the interval so the two pollers don't
|
||||
# hammer the network at the same instant.
|
||||
# Offset the fallback by half the interval so the two pollers don't hit
|
||||
# upstream at the same instant. APScheduler treats next_run_time=None as
|
||||
# "paused" (job never fires) — must be an actual datetime.
|
||||
from datetime import datetime as _dt, timezone as _tz, timedelta as _td
|
||||
offset = settings.truth_social_poll_seconds // 2
|
||||
_scheduler.add_job(
|
||||
poll_trumpstruth,
|
||||
"interval",
|
||||
@@ -77,7 +82,7 @@ async def lifespan(app: FastAPI):
|
||||
id="trumpstruth_poll",
|
||||
max_instances=1,
|
||||
coalesce=True,
|
||||
next_run_time=None, # APScheduler will pick a fresh slot
|
||||
next_run_time=_dt.now(_tz.utc) + _td(seconds=offset),
|
||||
)
|
||||
_scheduler.start()
|
||||
logger.info(
|
||||
|
||||
Reference in New Issue
Block a user