diff options
author | Jeff Huth <jeff.huth@bytecode.io> | 2019-11-15 00:49:39 -0800 |
---|---|---|
committer | Jeff Huth <jeff.huth@bytecode.io> | 2019-11-15 00:49:39 -0800 |
commit | da690bda91ea6a14964a2378e5dbb5d4de91a7e2 (patch) | |
tree | 5674346c5615e6d5dce5982c282af6580563bcc8 /tap_google_sheets/client.py | |
parent | 3eed42f0063de695f0a9199bf32bf38652e5b7ed (diff) | |
download | tap-google-sheets-da690bda91ea6a14964a2378e5dbb5d4de91a7e2.tar.gz tap-google-sheets-da690bda91ea6a14964a2378e5dbb5d4de91a7e2.tar.zst tap-google-sheets-da690bda91ea6a14964a2378e5dbb5d4de91a7e2.zip |
client.py rate limit, sync.py changes
client.py rate limit, fix json schemas, sync.py many changes
Diffstat (limited to 'tap_google_sheets/client.py')
-rw-r--r-- | tap_google_sheets/client.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/tap_google_sheets/client.py b/tap_google_sheets/client.py index 12f0811..0a0ce5a 100644 --- a/tap_google_sheets/client.py +++ b/tap_google_sheets/client.py | |||
@@ -151,6 +151,7 @@ class GoogleClient: # pylint: disable=too-many-instance-attributes | |||
151 | def __exit__(self, exception_type, exception_value, traceback): | 151 | def __exit__(self, exception_type, exception_value, traceback): |
152 | self.__session.close() | 152 | self.__session.close() |
153 | 153 | ||
154 | |||
154 | @backoff.on_exception(backoff.expo, | 155 | @backoff.on_exception(backoff.expo, |
155 | Server5xxError, | 156 | Server5xxError, |
156 | max_tries=5, | 157 | max_tries=5, |
@@ -187,13 +188,13 @@ class GoogleClient: # pylint: disable=too-many-instance-attributes | |||
187 | LOGGER.info('Authorized, token expires = {}'.format(self.__expires)) | 188 | LOGGER.info('Authorized, token expires = {}'.format(self.__expires)) |
188 | 189 | ||
189 | 190 | ||
191 | # Rate Limit: https://developers.google.com/sheets/api/limits | ||
192 | # 100 request per 100 seconds per User | ||
190 | @backoff.on_exception(backoff.expo, | 193 | @backoff.on_exception(backoff.expo, |
191 | (Server5xxError, ConnectionError, Server429Error), | 194 | (Server5xxError, ConnectionError, Server429Error), |
192 | max_tries=7, | 195 | max_tries=7, |
193 | factor=3) | 196 | factor=3) |
194 | # Rate Limit: | 197 | @utils.ratelimit(100, 100) |
195 | # https://developers.google.com/webmaster-tools/search-console-api-original/v3/limits | ||
196 | @utils.ratelimit(1200, 60) | ||
197 | def request(self, method, path=None, url=None, api=None, **kwargs): | 198 | def request(self, method, path=None, url=None, api=None, **kwargs): |
198 | 199 | ||
199 | self.get_access_token() | 200 | self.get_access_token() |
@@ -211,6 +212,7 @@ class GoogleClient: # pylint: disable=too-many-instance-attributes | |||
211 | del kwargs['endpoint'] | 212 | del kwargs['endpoint'] |
212 | else: | 213 | else: |
213 | endpoint = None | 214 | endpoint = None |
215 | LOGGER.info('{} URL = {}'.format(endpoint, url)) | ||
214 | 216 | ||
215 | if 'headers' not in kwargs: | 217 | if 'headers' not in kwargs: |
216 | kwargs['headers'] = {} | 218 | kwargs['headers'] = {} |