Skip to content

Commit

Permalink
fix(source): add manual override to _set_wait
Browse files Browse the repository at this point in the history
  • Loading branch information
engisalor committed Dec 1, 2022
1 parent 98e331d commit 56ca19c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions corpusama/source/call.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,14 @@ def _enforce_quota(self):
logger.debug(f"reached {self.calls_made}")
raise SystemExit()

def _set_wait(self):
def _set_wait(self, manual=None):
"""Sets a wait time between API calls.
Example wait_dict: `{0: 1, 5: 49, 10: 99, 20: 499, 30: None}`
Where: keys = seconds to wait and values = the maximum number of
calls allowed before increasing the wait time.
A `None` value indicates the largest possible wait time."""
A `None` value indicates the largest possible wait time.
Manual, int, overrides the wait dict"""

waits = []
for k, v in self.wait_dict.items():
Expand All @@ -60,8 +61,10 @@ def _set_wait(self):
if not waits:
waits.append(max([k for k in self.wait_dict.keys()]))

logger.debug(f"{min(waits)} second(s)")
self.wait = min(waits)
if manual:
self.wait = manual
logger.debug(f"{self.wait}")

def _get_parameters(self):
"""Loads API call parameters from a dict."""
Expand Down

0 comments on commit 56ca19c

Please sign in to comment.