Skip to content

Commit

Permalink
Prepare request retry
Browse files Browse the repository at this point in the history
  • Loading branch information
Nir Rattner committed Jan 29, 2016
1 parent c7bc60c commit 92937d0
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions hapi/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ def _digest_result(self, data):

return data

def _prepare_request_retry(self, method, url, headers, data):
pass

def _call_raw(self, subpath, params=None, method='GET', data=None, doseq=False, query='', retried=False, **options):
opts = self.options.copy()
opts.update(options)
Expand Down Expand Up @@ -195,6 +198,7 @@ def _call_raw(self, subpath, params=None, method='GET', data=None, doseq=False,
# Don't retry errors from 300 to 499
if e.result and e.result.status >= 300 and e.result.status < 500:
raise
self._prepare_request_retry(method, url, headers, data)
self.log.warning('HapiError %s calling %s, retrying' % (e, url))
# exponential back off - wait 0 seconds, 1 second, 3 seconds, 7 seconds, 15 seconds, etc.
time.sleep((pow(2, try_count - 1) - 1) * self.sleep_multiplier)
Expand Down

0 comments on commit 92937d0

Please sign in to comment.