diff options
-rw-r--r-- | CHANGES | 1 | ||||
-rw-r--r-- | redis/asyncio/connection.py | 7 | ||||
-rw-r--r-- | redis/connection.py | 7 |
3 files changed, 9 insertions, 6 deletions
@@ -1,3 +1,4 @@ + * asyncio: Fix memory leak caused by hiredis (#2693) * Allow data to drain from async PythonParser when reading during a disconnect() * Use asyncio.timeout() instead of async_timeout.timeout() for python >= 3.11 (#2602) * Add test and fix async HiredisParser when reading during a disconnect() (#2349) diff --git a/redis/asyncio/connection.py b/redis/asyncio/connection.py index 58dcd66..59f75aa 100644 --- a/redis/asyncio/connection.py +++ b/redis/asyncio/connection.py @@ -187,12 +187,13 @@ class BaseParser: except Exception: pass - def parse_error(self, response: str) -> ResponseError: + @classmethod + def parse_error(cls, response: str) -> ResponseError: """Parse an error response""" error_code = response.split(" ")[0] - if error_code in self.EXCEPTION_CLASSES: + if error_code in cls.EXCEPTION_CLASSES: response = response[len(error_code) + 1 :] - exception_class = self.EXCEPTION_CLASSES[error_code] + exception_class = cls.EXCEPTION_CLASSES[error_code] if isinstance(exception_class, dict): exception_class = exception_class.get(response, ResponseError) return exception_class(response) diff --git a/redis/connection.py b/redis/connection.py index 162a4c3..eefdd96 100644 --- a/redis/connection.py +++ b/redis/connection.py @@ -158,12 +158,13 @@ class BaseParser: "NOPERM": NoPermissionError, } - def parse_error(self, response): + @classmethod + def parse_error(cls, response): "Parse an error response" error_code = response.split(" ")[0] - if error_code in self.EXCEPTION_CLASSES: + if error_code in cls.EXCEPTION_CLASSES: response = response[len(error_code) + 1 :] - exception_class = self.EXCEPTION_CLASSES[error_code] + exception_class = cls.EXCEPTION_CLASSES[error_code] if isinstance(exception_class, dict): exception_class = exception_class.get(response, ResponseError) return exception_class(response) |