Skip to content

Commit b19bf9c

Browse files
committed
Remove GitHub ratelimit threshold
Original idea behind the threshold was to keep 10% of ratelimit for manual checks by user, but this didn't work as expected as even the manual checks were hitting this threshold. It would be better to rather use the whole ratelimit. Signed-off-by: Michal Konecny <mkonecny@redhat.com>
1 parent d387098 commit b19bf9c

File tree

3 files changed

+2
-33
lines changed

3 files changed

+2
-33
lines changed

anitya/lib/backends/github.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,6 @@
1818

1919
API_URL = "https://api.github.com/graphql"
2020

21-
"""
22-
Rate limit threshold (percent)
23-
10 percent of limit is left for users
24-
"""
25-
RATE_LIMIT_THRESHOLD = 0.1
26-
2721
_log = logging.getLogger(__name__)
2822

2923
"""
@@ -210,7 +204,6 @@ def parse_json(json, project):
210204
# We need to check limit first,
211205
# because exceeding the limit will also return error
212206
try:
213-
limit = json["data"]["rateLimit"]["limit"]
214207
remaining = json["data"]["rateLimit"]["remaining"]
215208
reset_time = json["data"]["rateLimit"]["resetAt"]
216209
_log.debug(
@@ -219,7 +212,7 @@ def parse_json(json, project):
219212
reset_time,
220213
)
221214

222-
if (remaining / limit) <= RATE_LIMIT_THRESHOLD:
215+
if remaining <= 0:
223216
raise RateLimitException(reset_time)
224217
except KeyError:
225218
_log.info("Github API ratelimit key is missing. Checking for errors.")

anitya/tests/lib/backends/test_github.py

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -627,31 +627,6 @@ def test_parse_json_threshold_exceeded(self):
627627
backend.parse_json(json, self.project)
628628
self.assertEqual(backend.reset_time, "2008-09-03T20:56:35.450686")
629629

630-
def test_parse_json_threshold_reached(self):
631-
"""
632-
Assert that exception is thrown when
633-
rate limit threshold is reached.
634-
"""
635-
project = models.Project(
636-
name="foobar",
637-
homepage="https://foobar.com",
638-
version_url="foo/bar",
639-
backend=BACKEND,
640-
)
641-
json = {
642-
"data": {
643-
"repository": {"refs": {"totalCount": 0}},
644-
"rateLimit": {
645-
"limit": 5000,
646-
"remaining": 500,
647-
"resetAt": "2008-09-03T20:56:35.450686",
648-
},
649-
}
650-
}
651-
with self.assertRaises(RateLimitException):
652-
backend.parse_json(json, project)
653-
self.assertEqual(backend.reset_time, "2008-09-03T20:56:35.450686")
654-
655630
def test_parse_json_tag_missing(self):
656631
"""Test parsing a JSON skips releases where tag is missing."""
657632
project = models.Project(

news/PR1968.bug

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Remove ratelimit threshold for GitHub

0 commit comments

Comments
 (0)