Fix memory leak of Stream objects in HTTP20Connection

This commit is contained in:
Lazarev Ivan
2016-12-25 01:34:45 +03:00
committed by Sergey Petrov
parent 15ca6f6b62
commit 92a04546f9
+5 -4
View File
@@ -37,7 +37,8 @@ class APNsClient(object):
url = '/3/device/{}'.format(token_hex) url = '/3/device/{}'.format(token_hex)
stream_id = self.__connection.request('POST', url, json_payload, headers) stream_id = self.__connection.request('POST', url, json_payload, headers)
resp = self.__connection.get_response(stream_id) resp = self.__connection.get_response(stream_id)
if resp.status != 200: with resp:
raw_data = resp.read().decode('utf-8') if resp.status != 200:
data = json.loads(raw_data) raw_data = resp.read().decode('utf-8')
raise exception_class_for_reason(data['reason']) data = json.loads(raw_data)
raise exception_class_for_reason(data['reason'])