Skip to content

Commit

Permalink
fix: increase the number of requests per second
Browse files Browse the repository at this point in the history
  • Loading branch information
am6010 committed Oct 3, 2024
1 parent b0a65bb commit 1d1f58e
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

BEGIN_TIME_PARAM = "begin_time"
END_TIME_PARAM = "end_time"
RATE_LIMIT_SLEEP_IN_SECS = 0.16

CAMEL_CASE_PATTERN = re.compile(r"(?<!^)(?=[A-Z])")

Expand Down Expand Up @@ -138,7 +139,7 @@ def read_records(
# slow down the API calls to avoid rate limiting
# https://recurly.com/developers/api-v2/v2.2/#section/Rate-Limits
# making 5 API calls per second / 300 API calls per minute / 1500 API calls per 5 minutes
time.sleep(0.2)
time.sleep(RATE_LIMIT_SLEEP_IN_SECS)

def get_updated_state(self, current_stream_state: MutableMapping[str, Any], latest_record: Mapping[str, Any]):
"""
Expand Down Expand Up @@ -216,7 +217,7 @@ def read_records(
for item in page:
yield self._item_to_dict(item)
# slow down the API calls to avoid rate limiting
time.sleep(0.2)
time.sleep(RATE_LIMIT_SLEEP_IN_SECS)
except MissingFeatureError as error:
super().logger.warning(f"Missing feature error {error}")

Expand Down Expand Up @@ -343,6 +344,6 @@ def read_records(
for item in page:
yield self._item_to_dict(item)
# slow down the API calls to avoid rate limiting
time.sleep(0.2)
time.sleep(RATE_LIMIT_SLEEP_IN_SECS)
except (NotFoundError, ValidationError):
pass

0 comments on commit 1d1f58e

Please sign in to comment.