Skip to content
This repository has been archived by the owner on Oct 13, 2023. It is now read-only.

Commit

Permalink
check ratelimit
Browse files Browse the repository at this point in the history
our health check job start multibranch at the same time, which maybe cause API call exceed rate limit, check rate limit before do anything if the number of requests remaining in the current rate limit window, sleep until next window come.
  • Loading branch information
Ximinhan committed Nov 22, 2021
1 parent 3982f51 commit ea01a16
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions doozerlib/cli/images_streams.py
Expand Up @@ -5,6 +5,7 @@
import json
import hashlib
import time
import datetime
import random

from github import Github, UnknownObjectException, GithubException
Expand Down Expand Up @@ -573,6 +574,9 @@ def images_upstreampulls(runtime):
if public_repo_url in upstreams:
continue
upstreams.add(public_repo_url)
rateLimit = github_client.get_rate_limit()
if rateLimit.core.remaining < 1000:
time.sleep((rateLimit.core.reset - datetime.datetime.now()).seconds)
public_source_repo = github_client.get_repo(f'{org}/{repo_name}')
pulls = public_source_repo.get_pulls(state='open', sort='created')
for pr in pulls:
Expand Down

0 comments on commit ea01a16

Please sign in to comment.