Skip to content

Commit

Permalink
chore(deps): Bump pyrate-limiter from 2.10.0 to 3.1.0 (#335)
Browse files Browse the repository at this point in the history
  • Loading branch information
dependabot[bot] authored Oct 17, 2023
1 parent f78eaa1 commit abf8d6d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
12 changes: 6 additions & 6 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ license = "Apache 2.0"

[tool.poetry.dependencies]
python = ">=3.8,<4"
pyrate-limiter = "==2.*"
pyrate-limiter = "==3.*"
requests-cache = "==1.*"
singer-sdk = "0.33.*"

Expand Down
11 changes: 7 additions & 4 deletions tap_stackexchange/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import logging
import typing as t

from pyrate_limiter import BucketFullException, Duration, Limiter, RequestRate
from pyrate_limiter import BucketFullException, Duration, Limiter, Rate
from requests_cache import install_cache
from singer_sdk.exceptions import RetriableAPIError
from singer_sdk.pagination import BasePageNumberPaginator
Expand Down Expand Up @@ -34,8 +34,8 @@ def has_backoff(response: requests.Response) -> bool:


install_cache(expire_after=3600, filter_fn=lambda r: not has_backoff(r)) # 1 hour
rate = RequestRate(100, Duration.MINUTE)
limiter = Limiter(rate)
rate = Rate(100, Duration.MINUTE)
limiter = Limiter(rate, max_delay=600)


class StackExchangePaginator(BasePageNumberPaginator):
Expand Down Expand Up @@ -98,7 +98,10 @@ def request_decorator(self, func: t.Callable) -> t.Callable:
Returns:
Decorated method.
"""
return limiter.ratelimit(self.tap_name, delay=True, max_delay=600)(func)
return limiter.as_decorator()(self._limiter_mapping)(func)

def _limiter_mapping(self, *_args: t.Any, **_kwargs: t.Any) -> tuple[str, int]:
return self.tap_name, 1

def validate_response(self, response: requests.Response) -> None:
"""Validate the HTTP response.
Expand Down

0 comments on commit abf8d6d

Please sign in to comment.