Skip to content

Comments

Fix rate limiting when 'Retry-After' is missing#161

Merged
balloob merged 1 commit intojkoelker:masterfrom
slemiere:master
Nov 19, 2018
Merged

Fix rate limiting when 'Retry-After' is missing#161
balloob merged 1 commit intojkoelker:masterfrom
slemiere:master

Conversation

@slemiere
Copy link
Contributor

Hello,

I was having the following issue when using this library.

  File "/usr/lib/python3.6/site-packages/nest/nest.py", line 578, in target
    self._set('devices/thermostats', data)
  File "/usr/lib/python3.6/site-packages/nest/nest.py", line 206, in _set
    response = self._nest_api._put(path=path, data=data)
  File "/usr/lib/python3.6/site-packages/nest/nest.py", line 1865, in _put
    return self._request('PUT', path, data=data)
  File "/usr/lib/python3.6/site-packages/nest/nest.py", line 1853, in _request
    default_wait=5)
  File "/usr/lib/python3.6/site-packages/nest/nest.py", line 1696, in _handle_ratelimit
    retry_after = response.headers['Retry-After']
  File "/usr/lib/python3.6/site-packages/requests/structures.py", line 52, in __getitem__
    return self._store[key.lower()][1]
KeyError: 'retry-after'

Looking into it it seems that Nest is not always sending back a retry-after header. I believe using get instead of the [] accessor should solve this issue.

@balloob
Copy link
Collaborator

balloob commented Nov 19, 2018

Looks good.

@balloob balloob merged commit 68efc6f into jkoelker:master Nov 19, 2018
@balloob balloob mentioned this pull request Nov 19, 2018
balloob added a commit that referenced this pull request Nov 19, 2018
* Fix rate limiting when 'Retry-After' is missing (#161)

* Version bump to 4.0.5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants