diff --git a/camply/cli.py b/camply/cli.py index 0b2330c1..c901282c 100644 --- a/camply/cli.py +++ b/camply/cli.py @@ -2,6 +2,7 @@ Camply Command Line Interface """ +import concurrent import logging import sys from dataclasses import dataclass @@ -20,6 +21,7 @@ ) import click +import tenacity from rich import traceback from rich_click import RichCommand, RichGroup, rich_click @@ -111,7 +113,9 @@ def _set_up_debug(debug: Optional[bool] = None) -> None: logger.debug("Camply Version: %s", __version__) logger.debug("Python Version: %s", sys.version.split(" ")[0]) logger.debug("Platform: %s", sys.platform) - traceback.install(show_locals=debug, suppress=[click, rich_click]) + traceback.install( + show_locals=debug, suppress=[click, rich_click, tenacity, concurrent] + ) def _preferred_provider(context: CamplyContext, command_provider: Optional[str]) -> str: diff --git a/camply/providers/going_to_camp/going_to_camp_provider.py b/camply/providers/going_to_camp/going_to_camp_provider.py index 506a70ff..9ababe30 100644 --- a/camply/providers/going_to_camp/going_to_camp_provider.py +++ b/camply/providers/going_to_camp/going_to_camp_provider.py @@ -8,8 +8,10 @@ from datetime import datetime from typing import Any, Dict, List, Optional, Tuple, Union +import tenacity from fake_useragent import UserAgent from pydantic import ValidationError +from requests.exceptions import Timeout from camply.containers import AvailableResource, CampgroundFacility, RecreationArea from camply.containers.base_container import GoingToCampEquipment @@ -485,6 +487,13 @@ def list_equipment_types(self, rec_area_id: int) -> Dict[str, int]: log_sorted_response(response_array=equipment_types) return equipment_types + @tenacity.retry( + retry=tenacity.retry_if_exception_type((ConnectionError, Timeout)), + wait=tenacity.wait_exponential(multiplier=3, max=1800), + stop=tenacity.stop.stop_after_delay(6000), + before_sleep=tenacity.before_sleep_log(logger, logging.WARNING), + reraise=True, + ) def list_site_availability( self, campground: CampgroundFacility,