summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Cleberg <[email protected]>2026-04-11 14:23:01 -0500
committerChristian Cleberg <[email protected]>2026-04-11 14:23:01 -0500
commite2a9508577f3c0d69dccad0c098a6da7fd95a363 (patch)
tree19b81365f749f4c30c9987b0d365409e0da361eb /src
parent9d88cda2826224aab5cda15424453ea1cad75ae0 (diff)
downloadhutch-stats-e2a9508577f3c0d69dccad0c098a6da7fd95a363.tar.gz
hutch-stats-e2a9508577f3c0d69dccad0c098a6da7fd95a363.tar.bz2
hutch-stats-e2a9508577f3c0d69dccad0c098a6da7fd95a363.zip
feat: run an initial poll when scheduler starts
Diffstat (limited to 'src')
-rw-r--r--src/srht_contrib/main.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/srht_contrib/main.py b/src/srht_contrib/main.py
index 9047bcc..c6038cb 100644
--- a/src/srht_contrib/main.py
+++ b/src/srht_contrib/main.py
@@ -2,6 +2,7 @@ from __future__ import annotations
from collections.abc import AsyncIterator
from contextlib import asynccontextmanager
+import logging
from apscheduler.schedulers.background import BackgroundScheduler
from fastapi import FastAPI
@@ -21,6 +22,9 @@ from srht_contrib.services.todo import TodoIngestionService
from srht_contrib.utils.identity import ActorIdentityResolver
+logger = logging.getLogger(__name__)
+
+
def build_poller(settings: Settings) -> PollerService:
todo_client = SourceHutGraphQLClient(settings.todo_srht_endpoint, settings.srht_token)
git_client = SourceHutGraphQLClient(settings.git_srht_endpoint, settings.srht_token)
@@ -68,6 +72,7 @@ def create_app(
replace_existing=True,
)
scheduler.start()
+ _run_startup_poll(app)
app.state.scheduler = scheduler
try:
yield
@@ -96,4 +101,11 @@ def _scheduled_poll(app: FastAPI) -> None:
db.close()
+def _run_startup_poll(app: FastAPI) -> None:
+ try:
+ _scheduled_poll(app)
+ except Exception:
+ logger.exception("Initial scheduled poll failed during application startup")
+
+
app = create_app()