Skip to content

Commit

Permalink
Backoff revision. (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
xacadil authored Jul 3, 2024
1 parent 92904a8 commit 8d60cd1
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion tap_restaurant365/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@

from datetime import timedelta
from http import HTTPStatus
from typing import Any, Callable, Optional
from typing import Any, Callable, Generator
from urllib.parse import parse_qs, urlparse

import backoff
import requests
from dateutil import parser
from singer_sdk.authenticators import BasicAuthenticator
Expand Down Expand Up @@ -115,3 +116,24 @@ def validate_response(self, response: requests.Response) -> None:
):
msg = self.response_error_message(response)
raise FatalAPIError(msg)

def backoff_wait_generator(self) -> Generator[float, None, None]:
"""The wait generator used by the backoff decorator on request failure.
See for options:
https://github.com/litl/backoff/blob/master/backoff/_wait_gen.py
And see for examples: `Code Samples <../code_samples.html#custom-backoff>`_
Returns:
The wait generator
"""
return backoff.expo(factor=5)

def backoff_max_tries(self) -> int:
"""The number of attempts before giving up when retrying requests.
Returns:
Number of max retries.
"""
return 8

0 comments on commit 8d60cd1

Please sign in to comment.