Skip to content

Commit

Permalink
allow to configure retry logging
Browse files Browse the repository at this point in the history
  • Loading branch information
kalessin committed Dec 11, 2023
1 parent b8ab014 commit 8a93239
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions shub_workflow/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,18 @@ def resolve_project_id(project_id=None) -> Optional[int]:
ONE_MIN_IN_S = 60


DASH_RETRY_MAX = int(os.environ.get("DASH_RETRY_MAX", MINS_IN_A_DAY))
DASH_RETRY_WAIT_SECS = int(os.environ.get("DASH_RETRY_WAIT_SECS", ONE_MIN_IN_S))
DASH_RETRY_LOGGING_LEVEL = os.environ.get("DASH_RETRY_LOGGING_LEVEL", "ERROR")


dash_retry_decorator = retry(
# ServerError is the only ScrapinghubAPIError that should be retried. Don't capture ScrapinghubAPIError here
retry=retry_if_exception_type((ServerError, ReadTimeout, ConnectionError, HTTPError)),
before_sleep=before_sleep_log(logger, logging.ERROR),
before_sleep=before_sleep_log(logger, getattr(logging, DASH_RETRY_LOGGING_LEVEL)),
reraise=True,
stop=stop_after_attempt(MINS_IN_A_DAY),
wait=wait_fixed(ONE_MIN_IN_S),
stop=stop_after_attempt(DASH_RETRY_MAX),
wait=wait_fixed(DASH_RETRY_WAIT_SECS),
)


Expand Down

0 comments on commit 8a93239

Please sign in to comment.