Skip to content

Commit 0cd5168

Browse files
committed
asyncio: Fix memory leak caused by hiredis (#2693)
1 parent e1017fd commit 0cd5168

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

CHANGES

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
* asyncio: Fix memory leak caused by hiredis (#2693)
12
* Allow data to drain from async PythonParser when reading during a disconnect()
23
* Use asyncio.timeout() instead of async_timeout.timeout() for python >= 3.11 (#2602)
34
* Add test and fix async HiredisParser when reading during a disconnect() (#2349)

redis/asyncio/connection.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,12 +187,13 @@ def __del__(self):
187187
except Exception:
188188
pass
189189

190-
def parse_error(self, response: str) -> ResponseError:
190+
@classmethod
191+
def parse_error(cls, response: str) -> ResponseError:
191192
"""Parse an error response"""
192193
error_code = response.split(" ")[0]
193-
if error_code in self.EXCEPTION_CLASSES:
194+
if error_code in cls.EXCEPTION_CLASSES:
194195
response = response[len(error_code) + 1 :]
195-
exception_class = self.EXCEPTION_CLASSES[error_code]
196+
exception_class = cls.EXCEPTION_CLASSES[error_code]
196197
if isinstance(exception_class, dict):
197198
exception_class = exception_class.get(response, ResponseError)
198199
return exception_class(response)

redis/connection.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,12 +158,13 @@ class BaseParser:
158158
"NOPERM": NoPermissionError,
159159
}
160160

161-
def parse_error(self, response):
161+
@classmethod
162+
def parse_error(cls, response):
162163
"Parse an error response"
163164
error_code = response.split(" ")[0]
164-
if error_code in self.EXCEPTION_CLASSES:
165+
if error_code in cls.EXCEPTION_CLASSES:
165166
response = response[len(error_code) + 1 :]
166-
exception_class = self.EXCEPTION_CLASSES[error_code]
167+
exception_class = cls.EXCEPTION_CLASSES[error_code]
167168
if isinstance(exception_class, dict):
168169
exception_class = exception_class.get(response, ResponseError)
169170
return exception_class(response)

0 commit comments

Comments
 (0)