[common] explicitly handle HTTP status code 429

This commit is contained in:
Mike Fährmann 2017-10-13 22:43:38 +02:00
parent abfd2924a9
commit 9aecc67841
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88

View File

@ -65,8 +65,12 @@ class Extractor():
msg = exc
if not retries:
raise exception.HttpError(msg)
time.sleep(1 + max_retries - retries)
if response.status_code == 429: # Too Many Requests
waittime = float(response.headers.get("Retry-After", 10.0))
else:
waittime = 1
retries -= 1
time.sleep(waittime * (max_retries - retries))
def _get_auth_info(self):
"""Return authentication information as (username, password) tuple"""