From fc42a49ccbe76d8bb90603c20be905ebda193669 Mon Sep 17 00:00:00 2001 From: Juan Riaza Date: Fri, 1 May 2015 15:41:48 +0200 Subject: [PATCH] raise exception for explicit statuses --- hubstorage/batchuploader.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/hubstorage/batchuploader.py b/hubstorage/batchuploader.py index 58ca8f5..ba86d6f 100644 --- a/hubstorage/batchuploader.py +++ b/hubstorage/batchuploader.py @@ -146,10 +146,13 @@ def _tryupload(self, batch): url = batch['url'] offset = batch['offset'] for retryn in xrange(self.worker_max_retries): - emsg = '' try: r = self._upload(batch) - r.raise_for_status() + + if r.status_code == 429 or (500 <= r.status_code < 600): + http_error_msg = '%s Server Error: %s' % (r.status_code, r.reason) + raise requests.HTTPError(http_error_msg, response=r) + if not (200 <= r.status_code < 300): logger.warning('Discarding write to url=%s offset=%s: ' '[HTTP error %s] %s\n%s', url, offset,