Skip to content

Commit

Permalink
Recursively call the function if Retry-After has the value greater …
Browse files Browse the repository at this point in the history
…than 0 (#192)
  • Loading branch information
sgandhi1311 authored May 16, 2023
1 parent 371e962 commit 587949b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
9 changes: 5 additions & 4 deletions tap_github/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']))
Expand Down

0 comments on commit 587949b

Please sign in to comment.