Closed
Description
In get, post, etc., the logic is similar to the following:
def _get(self, path):
"""
GET data from Adafruit IO
:param str path: Formatted Adafruit IO URL from _compose_path
"""
response = self._http.get(
path, headers=self._create_headers(self._aio_headers[1])
)
self._handle_error(response)
json_data = response.json()
response.close()
return json_data
Note that in the case that self._handle_error()
throws, the response is not closed.
By using with ... as response:
, the response will be automatically closed. The explicit response.close()
call can probably be removed too.
I raise this issue because @kattni in discord mentioned encountering an espidf.MemoryError while using Adafruit IO_HTTP to retrieve the current time. However, I don't know if this is actually the cause of her problem.