mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-12-04 13:49:57 -05:00
Fallout winds: retry a batch once when the forecast service can't be connected to (#1019)
Some checks are pending
Backend Tests / api-tests (core) (push) Waiting to run
Backend Tests / api-tests (files) (push) Waiting to run
Backend Tests / api-tests (media) (push) Waiting to run
Backend Tests / api-tests (rest) (push) Waiting to run
Backend Tests / api-contract-tests (push) Waiting to run
Backend Tests / api-migrations-and-start (push) Waiting to run
CodeQL / Analyze (push) Waiting to run
Controller Tests / controller-tests (push) Waiting to run
Cypress Tests / cypress-component-tests (push) Waiting to run
Cypress Tests / cypress-e2e-tests (push) Waiting to run
Dead Code / vulture (push) Waiting to run
Jest Tests / jest-tests (push) Waiting to run
Some checks are pending
Backend Tests / api-tests (core) (push) Waiting to run
Backend Tests / api-tests (files) (push) Waiting to run
Backend Tests / api-tests (media) (push) Waiting to run
Backend Tests / api-tests (rest) (push) Waiting to run
Backend Tests / api-contract-tests (push) Waiting to run
Backend Tests / api-migrations-and-start (push) Waiting to run
CodeQL / Analyze (push) Waiting to run
Controller Tests / controller-tests (push) Waiting to run
Cypress Tests / cypress-component-tests (push) Waiting to run
Cypress Tests / cypress-e2e-tests (push) Waiting to run
Dead Code / vulture (push) Waiting to run
Jest Tests / jest-tests (push) Waiting to run
A connection failure on any batch failed the whole daily download, discarding the batches already fetched and deferring the field to the next day. A batch which can't connect is now asked again a minute later, once, as an HTTP 429 already is. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
4c9f413322
commit
f58c86af88
2 changed files with 44 additions and 2 deletions
|
|
@ -26,6 +26,7 @@ from pathlib import Path
|
|||
from typing import List, Optional, Sequence, Tuple
|
||||
from urllib.parse import urlencode
|
||||
|
||||
import aiohttp
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from modules.map.lib import get_map_directory
|
||||
|
|
@ -195,7 +196,8 @@ async def request_forecast(url: str) -> list:
|
|||
|
||||
async def request_batch(url: str) -> list:
|
||||
"""The forecasts of a request; asked once more, a minute later, when the service says too many
|
||||
have been asked of it."""
|
||||
have been asked of it, or could not be connected to (so the batches already fetched are not lost
|
||||
to a moment's outage)."""
|
||||
for attempt in range(2):
|
||||
try:
|
||||
return await request_forecast(url)
|
||||
|
|
@ -207,7 +209,11 @@ async def request_batch(url: str) -> list:
|
|||
except asyncio.TimeoutError as e:
|
||||
raise WindsError(f'The forecast service did not answer within {TIMEOUT} seconds') from e
|
||||
except Exception as e:
|
||||
raise WindsError(f'Could not reach the forecast service: {str(e) or type(e).__name__}') from e
|
||||
error = WindsError(f'Could not reach the forecast service: {str(e) or type(e).__name__}')
|
||||
if attempt or not isinstance(e, aiohttp.ClientConnectionError):
|
||||
raise error from e
|
||||
logger.warning(f'{error}; trying again in a minute')
|
||||
await asyncio.sleep(BATCH_SECONDS)
|
||||
|
||||
|
||||
async def fetch_wind_field(places: Sequence[Tuple[float, float]], progress=None, cancelled=None) -> dict:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue