From 9cfc3e378821e3ba5c8491137fb81dc1d839b8b8 Mon Sep 17 00:00:00 2001 From: "M. Adam Kendall" Date: Sun, 25 Jan 2015 21:33:57 -0500 Subject: [PATCH] Make sure we're returning the result of the recursive request --- lib/trakt/trakt.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/trakt/trakt.py b/lib/trakt/trakt.py index 86004bf1..a66f3659 100644 --- a/lib/trakt/trakt.py +++ b/lib/trakt/trakt.py @@ -29,7 +29,11 @@ class TraktAPI(): resp.raise_for_status() resp = resp.json() except (requests.HTTPError, requests.ConnectionError) as e: - if e.response.status_code == 401: + if e.response.status_code == 502: + # Retry the request, cloudflare had a proxying issue + logger.log(u"Retrying trakt api request: auth/login", logger.WARNING) + return self.validateAccount() + elif e.response.status_code == 401: raise traktAuthException(e) if 'token' in resp: self.token = resp['token'] @@ -57,7 +61,7 @@ class TraktAPI(): if e.response.status_code == 502: # Retry the request, cloudflare had a proxying issue logger.log(u"Retrying trakt api request: %s" % path, logger.WARNING) - self.traktRequest(path, data, method) + return self.traktRequest(path, data, method) elif e.response.status_code == 401: raise traktAuthException(e) elif e.response.status_code == 503: