Skip to content

Commit

Permalink
fix(readwise): added sleep decorator for ratelimit
Browse files Browse the repository at this point in the history
  • Loading branch information
rwxd committed Dec 25, 2022
1 parent 1f72dc8 commit 5fc6cfd
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion wallabag2readwise/readwise.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from typing import Generator
from datetime import datetime
from typing import Optional
from ratelimit import limits, RateLimitException
from ratelimit import limits, RateLimitException, sleep_and_retry
from backoff import on_exception, expo
from time import sleep

Expand Down Expand Up @@ -35,6 +35,7 @@ def _session(self) -> requests.Session:
return session

@on_exception(expo, RateLimitException, max_tries=8)
@sleep_and_retry
@limits(calls=240, period=60)
def _request(
self, method: str, endpoint: str, params: dict = {}, data: dict = {}
Expand All @@ -56,6 +57,7 @@ def get(self, endpoint: str, params: dict = {}) -> requests.Response:
return response

@on_exception(expo, RateLimitException, max_tries=8)
@sleep_and_retry
@limits(calls=20, period=60)
def get_with_limit_20(self, endpoint: str, params: dict = {}) -> requests.Response:
response = self.get(endpoint, params)
Expand Down

0 comments on commit 5fc6cfd

Please sign in to comment.