From 2252ea5cfa6b55903d1152c2fa159351b8f43415 Mon Sep 17 00:00:00 2001 From: Tim Jagenberg Date: Sat, 27 Jul 2019 22:26:28 +0200 Subject: [PATCH] requests_cache compatibility --- spotipy/client.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spotipy/client.py b/spotipy/client.py index 3e33a21..27dfbbe 100644 --- a/spotipy/client.py +++ b/spotipy/client.py @@ -128,7 +128,8 @@ class Spotify(object): raise SpotifyException(r.status_code, -1, '%s:\n %s' % (r.url, 'error'), headers=r.headers) finally: - r.connection.close() + if hasattr(r, "connection"): + r.connection.close() if r.text and len(r.text) > 0 and r.text != 'null': results = r.json() if self.trace: # pragma: no cover