diff --git a/CHANGELOG.md b/CHANGELOG.md index 4182f874..760a29af 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +# 2.0.4 + * Recursively call the function if `Retry-After` has the value greater than 0 [#192](https://github.com/singer-io/tap-github/pull/192) + # 2.0.3 * Handles the secondary rate limit - `Retry-After` [#191](https://github.com/singer-io/tap-github/pull/191) diff --git a/setup.py b/setup.py index 151dbf9c..e19b70d8 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ from setuptools import setup, find_packages setup(name='tap-github', - version='2.0.3', + version='2.0.4', description='Singer.io tap for extracting data from the GitHub API', author='Stitch', url='http://singer.io', diff --git a/tap_github/client.py b/tap_github/client.py index c7d7f880..9e846282 100644 --- a/tap_github/client.py +++ b/tap_github/client.py @@ -142,10 +142,11 @@ def rate_throttling(response): if "Retry-After" in response.headers: # handles the secondary rate limit seconds_to_sleep = int(response.headers['Retry-After']) - LOGGER.info("API rate limit exceeded. Tap will retry the data collection after %s seconds.", seconds_to_sleep) - time.sleep(seconds_to_sleep) - #returns True if tap sleeps - return True + if seconds_to_sleep > 0: + LOGGER.info("API rate limit exceeded. Tap will retry the data collection after %s seconds.", seconds_to_sleep) + time.sleep(seconds_to_sleep) + #returns True if tap sleeps + return True if 'X-RateLimit-Remaining' in response.headers: if int(response.headers['X-RateLimit-Remaining']) == 0: seconds_to_sleep = calculate_seconds(int(response.headers['X-RateLimit-Reset']))