mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-28 19:06:19 -05:00
Fallout winds: make the daily download at 23 past the hour (#1020)
Some checks failed
Backend Tests / api-tests (core) (push) Has been cancelled
Backend Tests / api-tests (files) (push) Has been cancelled
Backend Tests / api-tests (media) (push) Has been cancelled
Backend Tests / api-tests (rest) (push) Has been cancelled
Backend Tests / api-contract-tests (push) Has been cancelled
Backend Tests / api-migrations-and-start (push) Has been cancelled
CodeQL / Analyze (push) Has been cancelled
Controller Tests / controller-tests (push) Has been cancelled
Cypress Tests / cypress-component-tests (push) Has been cancelled
Cypress Tests / cypress-e2e-tests (push) Has been cancelled
Dead Code / vulture (push) Has been cancelled
Jest Tests / jest-tests (push) Has been cancelled
Some checks failed
Backend Tests / api-tests (core) (push) Has been cancelled
Backend Tests / api-tests (files) (push) Has been cancelled
Backend Tests / api-tests (media) (push) Has been cancelled
Backend Tests / api-tests (rest) (push) Has been cancelled
Backend Tests / api-contract-tests (push) Has been cancelled
Backend Tests / api-migrations-and-start (push) Has been cancelled
CodeQL / Analyze (push) Has been cancelled
Controller Tests / controller-tests (push) Has been cancelled
Cypress Tests / cypress-component-tests (push) Has been cancelled
Cypress Tests / cypress-e2e-tests (push) Has been cancelled
Dead Code / vulture (push) Has been cancelled
Jest Tests / jest-tests (push) Has been cancelled
Daily downloads are spread over the day in slots which fall on the hour, when the forecast service is busiest. On .5 its TLS handshake stalled for minutes there, failing the download. The weather downloader now schedules its next run itself, a day later at 23 minutes past the hour. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
f58c86af88
commit
68d8eadd69
2 changed files with 26 additions and 1 deletions
|
|
@ -20,6 +20,7 @@ a whole country takes a few minutes.
|
|||
import asyncio
|
||||
import json
|
||||
from dataclasses import dataclass
|
||||
from datetime import timedelta
|
||||
import time
|
||||
import math
|
||||
from pathlib import Path
|
||||
|
|
@ -299,6 +300,9 @@ _summary_cache = dict()
|
|||
# The weather subscription: one recurring Download of a field around the saved targets.
|
||||
WEATHER_URL = OPEN_METEO_URL
|
||||
WEATHER_DOWNLOADER = 'open_meteo'
|
||||
# The minute past the hour the daily download is made: the forecast service is busy with requests
|
||||
# made on the hour, sometimes too busy to answer a connection for minutes.
|
||||
WEATHER_MINUTE = 23
|
||||
|
||||
|
||||
def target_places() -> List[Tuple[float, float]]:
|
||||
|
|
@ -403,7 +407,12 @@ class WeatherDownloader(Downloader):
|
|||
def finalize_download(self, session: Session, download: Download, executed: ExecutedWeather) -> DownloadResult:
|
||||
if executed.error:
|
||||
return DownloadResult(success=False, error=executed.error)
|
||||
return DownloadResult(success=True, location='/map/manage')
|
||||
# The next day's download is at WEATHER_MINUTE past the hour this one finished in, rather than in
|
||||
# a daily slot (which are on the hour).
|
||||
finished = now()
|
||||
tomorrow = (finished + timedelta(days=1)).replace(minute=WEATHER_MINUTE, second=0, microsecond=0)
|
||||
return DownloadResult(success=True, location='/map/manage',
|
||||
retry_seconds=int((tomorrow - finished).total_seconds()))
|
||||
|
||||
|
||||
weather_downloader = WeatherDownloader()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue