From 63ef55e083d254e2c438835cd356309590bc4312 Mon Sep 17 00:00:00 2001 From: Robert Townley Date: Thu, 23 Aug 2018 17:12:38 -0400 Subject: [PATCH] further handle missing ratelimit-remaining headers when 0 API requests remain --- pyopenfec/utils.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pyopenfec/utils.py b/pyopenfec/utils.py index c322275..e78b12d 100644 --- a/pyopenfec/utils.py +++ b/pyopenfec/utils.py @@ -70,7 +70,10 @@ def _throttled_request(cls, url, params): cls.wait_time)) time.sleep(cls.wait_time) response = requests.get(url, params=params) - cls.ratelimit_remaining = int(response.headers['x-ratelimit-remaining']) + if 'x-ratelimit-remaining' in response.headers: + cls.ratelimit_remaining = int(response.headers['x-ratelimit-remaining']) + else: + cls.ratelimit_remaining = 0 cls.wait_time = 0.5 return response