[rhythmbox: 4/5] listenbrainz: close HTTPS connection after use
- From: Jonathan Matthew <jmatthew src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rhythmbox: 4/5] listenbrainz: close HTTPS connection after use
- Date: Sun, 18 Sep 2022 09:09:54 +0000 (UTC)
commit bbbc6e9bf80024fc217e1ed56a49adf566202ca8
Author: Philipp Wolfer <ph wolfer gmail com>
Date: Sun Sep 4 11:01:19 2022 +0200
listenbrainz: close HTTPS connection after use
Fixes #1824
plugins/listenbrainz/client.py | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
---
diff --git a/plugins/listenbrainz/client.py b/plugins/listenbrainz/client.py
index a0a454b27..8da663f93 100644
--- a/plugins/listenbrainz/client.py
+++ b/plugins/listenbrainz/client.py
@@ -122,9 +122,13 @@ class ListenBrainzClient:
}
body = json.dumps(data)
conn = HTTPSConnection(HOST_NAME, context=SSL_CONTEXT, timeout=self._timeout)
- conn.request("POST", PATH_SUBMIT, body, headers)
- response = conn.getresponse()
- response_text = response.read()
+ try:
+ conn.request("POST", PATH_SUBMIT, body, headers)
+ response = conn.getresponse()
+ response_text = response.read()
+ finally:
+ conn.close()
+
try:
response_data = json.loads(response_text)
except json.decoder.JSONDecodeError:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]