- utc_to_eastern: use zoneinfo instead of hardcoded EDT offset (-4) so start times are correct in both EST and EDT - standings: fetch before truncate so a failed API call doesn't wipe existing standings data - routes: call parse_games() once per request instead of three times - scheduler: wrap run_pending() in try/except so an unhandled exception doesn't kill the background thread Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
22 lines
525 B
Python
22 lines
525 B
Python
import logging
|
|
import time
|
|
|
|
import schedule
|
|
|
|
from app.api import refresh_scores
|
|
from app.standings import refresh_standings
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
def start_scheduler():
|
|
schedule.every(600).seconds.do(refresh_standings)
|
|
schedule.every(10).seconds.do(refresh_scores)
|
|
logger.info("Background scheduler started")
|
|
while True:
|
|
try:
|
|
schedule.run_pending()
|
|
except Exception:
|
|
logger.exception("Scheduler encountered an unexpected error")
|
|
time.sleep(1)
|