spyse-python icon indicating copy to clipboard operation
spyse-python copied to clipboard

spyse.response.RateLimitError: too many requests

Open fabelx opened this issue 3 years ago • 2 comments

from spyse import Client


def main():
    client = Client("token")
    q = client.get_quotas()


if __name__ == '__main__':
    main()

Traceback:

Traceback (most recent call last):
  File "/home/name/py-trash/privatbank/main.py", line 11, in <module>
    main()
  File "/home/name/py-trash/privatbank/main.py", line 7, in main
    q = client.get_quotas()
  File "/home/name/py-trash/venv/lib/python3.9/site-packages/spyse/client.py", line 106, in get_quotas
    response.check_errors()
  File "/home/name/py-trash/venv/lib/python3.9/site-packages/spyse/response.py", line 117, in check_errors
    raise RateLimitError(m)
spyse.response.RateLimitError: too many requests

Python 3.9.9

Package            Version
------------------ ---------
certifi            2021.10.8
charset-normalizer 2.0.11
dataclasses        0.6
dataclasses-json   0.5.6
idna               3.3
limiter            0.1.2
marshmallow        3.14.1
marshmallow-enum   1.5.1
mypy-extensions    0.4.3
pip                21.2.4
requests           2.26.0
responses          0.13.4
setuptools         58.0.4
six                1.16.0
spyse-python       2.2.3
token-bucket       0.2.0
typing_extensions  4.0.1
typing-inspect     0.7.1
urllib3            1.26.8
wheel              0.37.0

fabelx avatar Feb 02 '22 11:02 fabelx

I see the same with the domain_lookup example:

$ python domain_lookup.py 
Traceback (most recent call last):
  File "/home/fab/Documents/repos/spyse-python/examples/domain_lookup.py", line 8, in <module>
    d = client.get_domain_details('tesla.com')
  File "/home/fab/Documents/repos/spyse-python/spyse/client.py", line 157, in get_domain_details
    response.check_errors()
  File "/home/fab/Documents/repos/spyse-python/spyse/response.py", line 117, in check_errors
    raise RateLimitError(m)
spyse.response.RateLimitError: too many requests

fabaff avatar Feb 10 '22 15:02 fabaff

It looks like that the limiter doesn't cover the first requests (self.account = self.get_quotas()) and the actual request for the data comes to fast.

fabaff avatar Feb 10 '22 20:02 fabaff