mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-10 09:32:06 +00:00
Add retries for github api
This commit is contained in:
parent
90db762c87
commit
948fde52a7
@ -1,13 +1,33 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import time
|
||||
from env_helper import GITHUB_REPOSITORY
|
||||
|
||||
RETRY = 5
|
||||
|
||||
|
||||
def get_commit(gh, commit_sha, retry_count=RETRY):
|
||||
for i in range(retry_count):
|
||||
try:
|
||||
repo = gh.get_repo(GITHUB_REPOSITORY)
|
||||
commit = repo.get_commit(commit_sha)
|
||||
return commit
|
||||
except Exception as ex:
|
||||
if i == retry_count - 1:
|
||||
raise ex
|
||||
time.sleep(i)
|
||||
|
||||
# just suppress warning
|
||||
return None
|
||||
|
||||
def get_commit(gh, commit_sha):
|
||||
repo = gh.get_repo(GITHUB_REPOSITORY)
|
||||
commit = repo.get_commit(commit_sha)
|
||||
return commit
|
||||
|
||||
def post_commit_status(gh, sha, check_name, description, state, report_url):
|
||||
commit = get_commit(gh, sha)
|
||||
commit.create_status(context=check_name, description=description, state=state, target_url=report_url)
|
||||
for i in range(RETRY):
|
||||
try:
|
||||
commit = get_commit(gh, sha, 1)
|
||||
commit.create_status(context=check_name, description=description, state=state, target_url=report_url)
|
||||
break
|
||||
except Exception as ex:
|
||||
if i == RETRY - 1:
|
||||
raise ex
|
||||
time.sleep(i)
|
||||
|
Loading…
Reference in New Issue
Block a user