Skip to content

Commit

Permalink
Lower search calls per second to 1
Browse files Browse the repository at this point in the history
  • Loading branch information
edsu committed Nov 1, 2023
1 parent 03b8388 commit 7ac515b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions wayback/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ class WaybackSession(_utils.DisableAfterCloseSession, requests.Session):
user_agent : str, optional
A custom user-agent string to use in all requests. Defaults to:
`wayback/{version} (+https://github.com/edgi-govdata-archiving/wayback)`
search_calls_per_second : int or float, default: 1.5
search_calls_per_second : int or float, default: 1
The maximum number of calls made to the search API per second.
To disable the rate limit, set this to 0.
memento_calls_per_second : int or float, default: 30
Expand All @@ -366,7 +366,7 @@ class WaybackSession(_utils.DisableAfterCloseSession, requests.Session):
handleable_errors = (ConnectionError,) + retryable_errors

def __init__(self, retries=6, backoff=2, timeout=60, user_agent=None,
search_calls_per_second=1.5, memento_calls_per_second=30):
search_calls_per_second=1, memento_calls_per_second=30):
super().__init__()
self.retries = retries
self.backoff = backoff
Expand Down
2 changes: 1 addition & 1 deletion wayback/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ def set_memento_url_mode(url, mode):


@contextmanager
def rate_limited(calls_per_second=2, group='default'):
def rate_limited(calls_per_second=1, group='default'):
"""
A context manager that restricts entries to its body to occur only N times
per second (N can be a float). The current thread will be put to sleep in
Expand Down
2 changes: 1 addition & 1 deletion wayback/tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,7 @@ def test_search_rate_limits(self):
next(client.search('zew.de'))
duration_with_limits_custom = time.time() - start_time

assert 1.3 <= duration_with_limits <= 1.4
assert 1.9 <= duration_with_limits <= 2.1
assert 0.0 <= duration_without_limits <= 0.05
assert 0.0 <= duration_with_limits_custom <= 1.05

Expand Down

0 comments on commit 7ac515b

Please sign in to comment.