swh.lister.gitlab: Make rate limit check optional
Samples: - https://0xacab.org/api/v4/projects/ - https://framagit.org/api/v4/projects/ - https://salsa.debian.org/api/v4/projects/ - https://gitlab.com/api/v4/projects/ - https://gitlab.freedesktop.org/api/v4/projects/ - https://gitlab.gnome.org/api/v4/projects/ - https://gitlab.inria.fr/api/v4/projects/ Related T989
This commit is contained in:
parent
79cd00737f
commit
3ca566776f
1 changed files with 8 additions and 6 deletions
|
@ -87,14 +87,16 @@ class GitLabLister(SWHPagingHttpLister):
|
|||
}
|
||||
|
||||
def transport_quota_check(self, response):
|
||||
"""Deal with rate limit
|
||||
"""Deal with rate limit if any.
|
||||
|
||||
"""
|
||||
reqs_remaining = int(response.headers['RateLimit-Remaining'])
|
||||
if response.status_code == 403 and reqs_remaining == 0:
|
||||
reset_at = int(response.headers['RateLimit-Reset'])
|
||||
delay = min(reset_at - time.time(), 3600)
|
||||
return True, delay
|
||||
# not all gitlab instance have rate limit
|
||||
if 'RateLimit-Remaining' in response.headers:
|
||||
reqs_remaining = int(response.headers['RateLimit-Remaining'])
|
||||
if response.status_code == 403 and reqs_remaining == 0:
|
||||
reset_at = int(response.headers['RateLimit-Reset'])
|
||||
delay = min(reset_at - time.time(), 3600)
|
||||
return True, delay
|
||||
return False, 0
|
||||
|
||||
def get_next_target_from_response(self, response):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue