Skip to content

Commit 64ce5f6

Browse files
author
brentru
committed
close the socket after making a request, only return the json data
1 parent 2ae8741 commit 64ce5f6

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

adafruit_io/adafruit_io.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,9 @@ def _post(self, path, payload):
118118
json=payload,
119119
headers=self._create_headers(self._aio_headers[0]))
120120
self._handle_error(response)
121-
return response.json()
121+
json_data = response.json()
122+
response.close()
123+
return json_data
122124

123125
def _get(self, path):
124126
"""
@@ -129,7 +131,9 @@ def _get(self, path):
129131
path,
130132
headers=self._create_headers(self._aio_headers[1]))
131133
self._handle_error(response)
132-
return response.json()
134+
json_data = response.json()
135+
response.close()
136+
return json_data
133137

134138
def _delete(self, path):
135139
"""
@@ -140,7 +144,9 @@ def _delete(self, path):
140144
path,
141145
headers=self._create_headers(self._aio_headers[0]))
142146
self._handle_error(response)
143-
return response.json()
147+
json_data = response.json()
148+
response.close()
149+
return json_data
144150

145151
# Data
146152
def send_data(self, feed_key, data, metadata=None, precision=None):

0 commit comments

Comments
 (0)