Festlegen der API -Ratenlimit auf Python mit der Ratelimit -Bibliothek

Post a reply

Smilies
:) :( :oops: :chelo: :roll: :wink: :muza: :sorry: :angel: :read: *x) :clever:
View more smilies

BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: Festlegen der API -Ratenlimit auf Python mit der Ratelimit -Bibliothek

by Anonymous » 02 May 2025, 05:37

Code: Select all

 from ratelimit import limits, RateLimitException, sleep_and_retry
from backoff import on_exception, expo
max_hit = 5
period = 300
@limits(calls=max_hit, period=period)
def StashNotes(self):
url = ("https://www.r10.net/")
raw_data = requests.get(url, headers=headers)
if raw_data.status_code != 200:
raise Exception('API response: {}'.format(raw_data.status_code))
else:
## some unnecessary things here ##
< /code>
Ich versuche, die API -Rate mit einem maximalen Treffer von 5 und Periode 300 zu begrenzen, sodass meine Anfragen in 300 Sekunden nicht mehr als das Fünf -mal -Mal auftreten. @Limits (Calls = max_hit, Periode = Periode) funktioniert nicht und kann nicht wirklich herausfinden, warum. Jede Art von Lösung wird geschätzt, danke. < /P>
headers=headers
enthält vertrauliche Informationen, aber es ist sowieso egal nur 2 Cookie -Werte darin.

Top