Skip to content

Commit

Permalink
Version bump to 4.0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
balloob committed Nov 19, 2018
1 parent 68efc6f commit ad5476c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
23 changes: 12 additions & 11 deletions nest/nest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1699,24 +1699,25 @@ def _handle_ratelimit(self, res, verb, url, data,
retries = 0
while response.status_code == 429 and retries <= max_retries:
retries += 1
retry_after = response.headers.get('Retry-After', 'N/A')
retry_after = response.headers.get('Retry-After')
_LOGGER.info("Reach rate limit, retry (%d), after %s",
retries, retry_after)
# Default Retry Time
wait = default_wait

try:
# Checks if retry_after is a number
wait = float(retry_after)
except ValueError:
# If not:
if retry_after is not None:
try:
# Checks if retry_after is a HTTP date
now = datetime.datetime.now()
wait = (now - parse_time(retry_after)).total_seconds()
# Checks if retry_after is a number
wait = float(retry_after)
except ValueError:
# Does nothing and uses default (shouldn't happen)
pass
# If not:
try:
# Checks if retry_after is a HTTP date
now = datetime.datetime.now()
wait = (now - parse_time(retry_after)).total_seconds()
except ValueError:
# Use default
pass

_LOGGER.debug("Wait %d seconds.", wait)
time.sleep(wait)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# Bumping Minor means API bugfix or new functionality.
# Bumping Micro means CLI change of any kind unless it is
# significant enough to warrant a minor/major bump.
version = '4.0.4'
version = '4.0.5'


setup(name='python-nest',
Expand Down

0 comments on commit ad5476c

Please sign in to comment.