Skip to content

Commit beab3dc

Browse files
Suggestion to download data in batches when encountering 504 on downloading data (#125)
1 parent 26998b8 commit beab3dc

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

datareservoirio/client.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,10 @@ def get(
392392
+ f"timeseries/{series_id}/data/days?start={start}&end={end}",
393393
timeout=_TIMEOUT_DEAULT,
394394
)
395+
if response.status_code == 504:
396+
raise TimeoutError(
397+
"Gateway Timeout. Try downloading data in smaller batches, preferably with a daily interval. See documentation for guidance: https://docs.4insight.io/dataanalytics/reservoir/python/latest/user_guide/dos_donts.html."
398+
)
395399
response.raise_for_status()
396400
response_json = response.json()
397401

@@ -548,6 +552,10 @@ def get_samples_aggregate_page(url):
548552

549553
while next_page_link:
550554
response = get_samples_aggregate_page(next_page_link)
555+
if response.status_code == 504:
556+
raise TimeoutError(
557+
"Gateway Timeout. Try downloading data in smaller batches, preferably with a daily interval. See documentation for guidance: https://docs.4insight.io/dataanalytics/reservoir/python/latest/user_guide/dos_donts.html."
558+
)
551559
response.raise_for_status()
552560
response_json = response.json()
553561
next_page_link = response_json.get("@odata.nextLink", None)

0 commit comments

Comments
 (0)