[twitter] add 'ratelimit' option (#4251)

pull/4291/head
Mike Fährmann 1 year ago
parent f86fdf64a6
commit 1bf9f52c99
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88

@ -3183,6 +3183,19 @@ Description
a quoted (original) Tweet when it sees the Tweet which quotes it.
extractor.twitter.ratelimit
---------------------------
Type
``string``
Default
``"wait"``
Description
Selects how to handle exceeding the API rate limit.
* ``"abort"``: Raise an error and stop extraction
* ``"wait"``: Wait until rate limit reset
extractor.twitter.replies
-------------------------
Type

@ -1439,6 +1439,9 @@ class TwitterAPI():
if response.status_code == 429:
# rate limit exceeded
if self.extractor.config("ratelimit") == "abort":
raise exception.StopExtraction("Rate limit exceeded")
until = response.headers.get("x-rate-limit-reset")
seconds = None if until else 60
self.extractor.wait(until=until, seconds=seconds)

Loading…
Cancel
Save