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):