From 92937d04faf6ac0c3796b5e49200594d3c541dd6 Mon Sep 17 00:00:00 2001 From: Nir Rattner Date: Thu, 28 Jan 2016 22:10:06 -0500 Subject: [PATCH] Prepare request retry --- hapi/base.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hapi/base.py b/hapi/base.py index 6298a44..1109642 100644 --- a/hapi/base.py +++ b/hapi/base.py @@ -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) @@ -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)