From 85efc31c1044ffab820e51133196d9c99310b37c Mon Sep 17 00:00:00 2001 From: Hugo Date: Wed, 11 Apr 2018 10:38:00 +0300 Subject: [PATCH] Close HTTPSConnection in case of exception --- pylast/__init__.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pylast/__init__.py b/pylast/__init__.py index 195a649..16dc353 100644 --- a/pylast/__init__.py +++ b/pylast/__init__.py @@ -857,8 +857,10 @@ class _Request(object): except Exception as e: raise MalformedResponseError(self.network, e) - self._check_response_for_errors(response_text) - conn.close() + try: + self._check_response_for_errors(response_text) + finally: + conn.close() return response_text def execute(self, cacheable=False):