From f021265663f5df43d6ae4445d17076bb5c6d4e1f Mon Sep 17 00:00:00 2001 From: Leonhardt Wille Date: Mon, 20 Feb 2017 11:20:16 +0100 Subject: [PATCH] fix: UnboundLocalError: local variable 'response' referenced before assignment --- marathon/client.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/marathon/client.py b/marathon/client.py index a57256d..d83f4c9 100644 --- a/marathon/client.py +++ b/marathon/client.py @@ -119,11 +119,12 @@ def _do_sse_request(self, path): headers={'Accept': 'text/event-stream'}, auth=self.auth ) + if response.ok: + return response.iter_lines() + response.raise_for_status() except Exception as e: marathon.log.error('Error while calling %s: %s', url, e.message) - if response.ok: - return response.iter_lines() raise MarathonError('No remaining Marathon servers to try')