Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4060146

Browse files
fix: support RateLimit-Reset header
Some endpoints are not returning the `Retry-After` header whenrate-limiting occurrs. In those cases use the `RateLimit-Reset` [1]header, if available.Closes:#1889[1]https://docs.gitlab.com/ee/user/admin_area/settings/user_and_ip_rate_limits.html#response-headers
1 parent85a734f commit4060146

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

‎gitlab/client.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -700,10 +700,14 @@ def http_request(
700700
if (429==result.status_codeandobey_rate_limit)or (
701701
result.status_codein [500,502,503,504]andretry_transient_errors
702702
):
703+
# Response headers documentation:
704+
# https://docs.gitlab.com/ee/user/admin_area/settings/user_and_ip_rate_limits.html#response-headers
703705
ifmax_retries==-1orcur_retries<max_retries:
704706
wait_time=2**cur_retries*0.1
705707
if"Retry-After"inresult.headers:
706708
wait_time=int(result.headers["Retry-After"])
709+
elif"RateLimit-Reset"inresult.headers:
710+
wait_time=int(result.headers["RateLimit-Reset"])-time.time()
707711
cur_retries+=1
708712
time.sleep(wait_time)
709713
continue

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp