Skip to content

Commit c2bc57e

Browse files
committed
Handle HTTP 429 errors in solar forecast API requests
1 parent d6f8905 commit c2bc57e

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

source/main.py

+5
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from types import FrameType
66

77
import pause
8+
import requests
89
from environment_variable_getter import EnvironmentVariableGetter
910
from inverter_charge_controller import InverterChargeController
1011
from logger import LoggerMixin
@@ -33,6 +34,10 @@ def write_solar_forecast_and_history_to_db() -> None:
3334

3435
try:
3536
sun_forecast_handler.retrieve_solar_data_from_api(start, end)
37+
except requests.exceptions.HTTPError as e:
38+
if e.response.status_code != 429:
39+
raise e
40+
logger.log.warning("Too many requests to the solar forecast API --> unable to log solar forecast data")
3641
except Exception:
3742
logger.log.error("Failed to log solar forecast data", exc_info=True)
3843
pass

0 commit comments

Comments
 (0)