Browse Source

Python 3 friendly way to re-raise when tries expire

pull/433/head
Ross McFarland 6 years ago
parent
commit
ea2a52c307
No known key found for this signature in database GPG Key ID: 61C10C4FC8FE4A89
1 changed files with 3 additions and 2 deletions
  1. +3
    -2
      octodns/provider/ns1.py

+ 3
- 2
octodns/provider/ns1.py View File

@ -31,17 +31,18 @@ class Ns1Client(object):
def _try(self, method, *args, **kwargs):
tries = self.retry_count
while tries:
while True: # We'll raise to break after our tries expire
try:
return method(*args, **kwargs)
except RateLimitException as e:
if tries <= 1:
raise
period = float(e.period)
self.log.warn('rate limit encountered, pausing '
'for %ds and trying again, %d remaining',
period, tries)
sleep(period)
tries -= 1
raise
def zones_retrieve(self, name):
return self._try(self._zones.retrieve, name)


Loading…
Cancel
Save