From 481f74caf1ffc649128bb8db84ac9104304420a9 Mon Sep 17 00:00:00 2001 From: Tim Burke <tim.burke@gmail.com> Date: Fri, 28 Oct 2016 12:19:35 +0200 Subject: [PATCH] Low-level API: Don't log just before raising an exception The only logging we should do is when we've encountered a problem *and we've dealt with it ourselves*. When we're raising an exception, it should be up to the caller to decide whether to log anything about it. Anything else is just rude. Change-Id: I1c96b76d90a78b7a10ffe63e4a7440c8f579147c Closes-Bug: 1213179 Related-Bug: 1202229 --- swiftclient/client.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/swiftclient/client.py b/swiftclient/client.py index b0d2bf35..6eefec4b 100644 --- a/swiftclient/client.py +++ b/swiftclient/client.py @@ -307,9 +307,8 @@ class _RetryBody(_ObjectBody): try: buf = self.resp.read(length) self.bytes_read += len(buf) - except (socket.error, RequestException) as e: + except (socket.error, RequestException): if self.conn.attempts > self.conn.retries: - logger.exception(e) raise if (not buf and self.bytes_read < self.expected_length and self.conn.attempts <= self.conn.retries): @@ -1659,10 +1658,9 @@ class Connection(object): return rv except SSLError: raise - except (socket.error, RequestException) as e: + except (socket.error, RequestException): self._add_response_dict(caller_response_dict, kwargs) if self.attempts > self.retries: - logger.exception(e) raise self.http_conn = None except ClientException as err: @@ -1677,11 +1675,9 @@ class Connection(object): self.url = self.token = self.service_token = None if retried_auth or not should_retry: - logger.exception(err) raise retried_auth = True elif self.attempts > self.retries or err.http_status is None: - logger.exception(err) raise elif err.http_status == 408: self.http_conn = None @@ -1690,7 +1686,6 @@ class Connection(object): elif self.retry_on_ratelimit and err.http_status == 498: pass else: - logger.exception(err) raise sleep(backoff) backoff = min(backoff * 2, self.max_backoff)