Skip to content

Commit

Permalink
Merge branch 'master' into kristjan/interrupt-2
Browse files Browse the repository at this point in the history
  • Loading branch information
kristjanvalur committed Apr 13, 2023
2 parents 2fefdf2 + db9a85c commit cf07d75
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
* Revert #2104, add `disconnect_on_error` option to `read_response()` (#2506)
* 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)
Expand Down
6 changes: 5 additions & 1 deletion docs/redismodules.rst
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,11 @@ below, an index named *my_index* is being created. When an index name is not spe
r = redis.Redis()
index_name = "my_index"
r.ft(index_name).create_index(TextField("play", weight=5.0), TextField("ball"))
schema = (
TextField("play", weight=5.0),
TextField("ball"),
)
r.ft(index_name).create_index(schema)
print(r.ft(index_name).info())
Expand Down
7 changes: 4 additions & 3 deletions redis/asyncio/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,12 +187,13 @@ def __del__(self):
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)
Expand Down
7 changes: 4 additions & 3 deletions redis/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
install_requires=[
'importlib-metadata >= 1.0; python_version < "3.8"',
'typing-extensions; python_version<"3.8"',
'async-timeout>=4.0.2; python_version<="3.11.2"',
'async-timeout>=4.0.2; python_full_version<="3.11.2"',
],
classifiers=[
"Development Status :: 5 - Production/Stable",
Expand Down

0 comments on commit cf07d75

Please sign in to comment.