Reporting an error when the user's rate limit is exceeded causes
the script to terminate after resuming execution from a rate limit
sleep. Instead of generating an explicit error we just want to
inform the user that the script is going to sleep until their rate
limit count resets.
This commit is contained in:
Jonas Michel
2016-01-20 14:48:02 -06:00
parent 9b74aff20b
commit 1e5a90486c

View File

@@ -299,10 +299,10 @@ def get_query_args(query_args=None):
def _get_response(request, auth, template): def _get_response(request, auth, template):
retry_timeout = 3 retry_timeout = 3
errors = []
# We'll make requests in a loop so we can # We'll make requests in a loop so we can
# delay and retry in the case of rate-limiting # delay and retry in the case of rate-limiting
while True: while True:
errors = []
should_continue = False should_continue = False
try: try:
r = urllib2.urlopen(request) r = urllib2.urlopen(request)
@@ -356,10 +356,9 @@ def _request_http_error(exc, auth, errors):
print('Exceeded rate limit of {} requests; waiting {} seconds to reset'.format(limit, delta), # noqa print('Exceeded rate limit of {} requests; waiting {} seconds to reset'.format(limit, delta), # noqa
file=sys.stderr) file=sys.stderr)
ratelimit_error = 'No more requests remaining'
if auth is None: if auth is None:
ratelimit_error += '; authenticate to raise your GitHub rate limit' # noqa print('Hint: Authenticate to raise your GitHub rate limit',
errors.append(ratelimit_error) file=sys.stderr)
time.sleep(delta) time.sleep(delta)
should_continue = True should_continue = True