From d542842a7a492aac03f5e0ddfea0221de3e5486c Mon Sep 17 00:00:00 2001 From: Ricardo Garcia Silva Date: Mon, 2 Dec 2024 11:53:48 +0000 Subject: [PATCH] Added config option for setting timeout of ncss-related requests Also set a default value of 30s (the previous value was 5s, which is httpx's default) --- arpav_ppcv/config.py | 1 + arpav_ppcv/webapp/api_v2/routers/coverages.py | 3 +++ 2 files changed, 4 insertions(+) diff --git a/arpav_ppcv/config.py b/arpav_ppcv/config.py index 6997bfdb..6a169756 100644 --- a/arpav_ppcv/config.py +++ b/arpav_ppcv/config.py @@ -47,6 +47,7 @@ class ThreddsServerSettings(pydantic.BaseModel): base_url: str = "http://localhost:8080/thredds" wms_service_url_fragment: str = "wms" netcdf_subset_service_url_fragment: str = "ncss/grid" # noqa + netcdf_subset_service_timeout_seconds: int = 30 # noqa opendap_service_url_fragment: str = "dodsC" # noqa uncertainty_visualization_scale_range: tuple[float, float] = pydantic.Field( default=(0, 9) diff --git a/arpav_ppcv/webapp/api_v2/routers/coverages.py b/arpav_ppcv/webapp/api_v2/routers/coverages.py index 673e71b2..cce31dc5 100644 --- a/arpav_ppcv/webapp/api_v2/routers/coverages.py +++ b/arpav_ppcv/webapp/api_v2/routers/coverages.py @@ -452,6 +452,9 @@ async def get_forecast_data( fitted_bbox = None cache_key = datadownloads.get_cache_key(coverage, fitted_bbox, temporal_range) + http_client.timeout = ( + settings.thredds_server.netcdf_subset_service_timeout_seconds + ) response_to_stream = await datadownloads.retrieve_coverage_data( settings, http_client, cache_key, coverage, fitted_bbox, temporal_range )