diff options
author | Mike Crute <mike@crute.us> | 2019-04-02 05:23:23 +0000 |
---|---|---|
committer | Mike Crute <mike@crute.us> | 2020-06-16 00:14:47 +0000 |
commit | 1080ae62dd6ae3a47b0f222537b5343f6715490f (patch) | |
tree | a17bbdb5d83262a9709bb64679c3ffb0c81e2ceb /pandora/clientbuilder.py | |
parent | 95b3f19c042b8dd582a46c1b58e2b0c5e81f4d5b (diff) | |
download | pydora-rate-limits.tar.bz2 pydora-rate-limits.tar.xz pydora-rate-limits.zip |
WIP: rate limitsrate-limits
Diffstat (limited to 'pandora/clientbuilder.py')
-rw-r--r-- | pandora/clientbuilder.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/pandora/clientbuilder.py b/pandora/clientbuilder.py index 2b11ffb..1eb3811 100644 --- a/pandora/clientbuilder.py +++ b/pandora/clientbuilder.py | |||
@@ -8,6 +8,7 @@ import os.path | |||
8 | 8 | ||
9 | from configparser import ConfigParser | 9 | from configparser import ConfigParser |
10 | from .client import APIClient | 10 | from .client import APIClient |
11 | from .ratelimit import WarningTokenBucket | ||
11 | from .transport import Encryptor, APITransport, DEFAULT_API_HOST | 12 | from .transport import Encryptor, APITransport, DEFAULT_API_HOST |
12 | 13 | ||
13 | 14 | ||
@@ -94,8 +95,9 @@ class APIClientBuilder: | |||
94 | 95 | ||
95 | DEFAULT_CLIENT_CLASS = APIClient | 96 | DEFAULT_CLIENT_CLASS = APIClient |
96 | 97 | ||
97 | def __init__(self, client_class=None): | 98 | def __init__(self, client_class=None, rate_limiter=WarningTokenBucket): |
98 | self.client_class = client_class or self.DEFAULT_CLIENT_CLASS | 99 | self.client_class = client_class or self.DEFAULT_CLIENT_CLASS |
100 | self.rate_limiter = rate_limiter | ||
99 | 101 | ||
100 | def build_from_settings_dict(self, settings): | 102 | def build_from_settings_dict(self, settings): |
101 | enc = Encryptor(settings["DECRYPTION_KEY"], settings["ENCRYPTION_KEY"]) | 103 | enc = Encryptor(settings["DECRYPTION_KEY"], settings["ENCRYPTION_KEY"]) |
@@ -116,6 +118,7 @@ class APIClientBuilder: | |||
116 | settings["PARTNER_PASSWORD"], | 118 | settings["PARTNER_PASSWORD"], |
117 | settings["DEVICE"], | 119 | settings["DEVICE"], |
118 | quality, | 120 | quality, |
121 | self.rate_limiter, | ||
119 | ) | 122 | ) |
120 | 123 | ||
121 | 124 | ||