Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding a sleep to streams/base.py prevent rate limiting issues #4

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ This tap:
{
"start_date": "2010-01-01",
"api_key": "<Chargebee API Key>",
"site": "<Chargebee Site>"
"site": "<Chargebee Site>",
"time_between_calls": None
}
```

Expand Down
4 changes: 4 additions & 0 deletions tap_chargebee/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def __init__(self, config, api_result_limit=100, include_deleted=True):
self.api_result_limit = api_result_limit
self.include_deleted = include_deleted
self.user_agent = self.config.get('user_agent')
self.time_between_calls = self.config.get('time_between_calls', None)

def get_headers(self):
headers = {}
Expand All @@ -41,6 +42,9 @@ def make_request(self, url, method, params=None, base_backoff=15,
if params is None:
params = {}

# sleep for desired amount to prevent rate limiting
if self.time_between_calls is not None:
time.sleep(self.time_between_calls)
LOGGER.info("Making {} request to {}".format(method, url))

response = requests.request(
Expand Down
1 change: 1 addition & 0 deletions tap_chargebee/streams/base.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import singer
import datetime

from dateutil.parser import parse
from tap_framework.streams import BaseStream
Expand Down