Skip to content

Commit

Permalink
Removing command on initial connections (#1722)
Browse files Browse the repository at this point in the history
  • Loading branch information
chayim authored Nov 17, 2021
1 parent e74ed19 commit 4e9cc01
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 32 deletions.
18 changes: 0 additions & 18 deletions redis/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -890,12 +890,6 @@ def __init__(self, host='localhost', port=6379,
self.response_callbacks = CaseInsensitiveDict(
self.__class__.RESPONSE_CALLBACKS)

# preload our class with the available redis commands
try:
self.__redis_commands__()
except RedisError:
pass

def __repr__(self):
return "%s<%s>" % (type(self).__name__, repr(self.connection_pool))

Expand Down Expand Up @@ -927,18 +921,6 @@ def load_external_module(self, funcname, func,
"""
setattr(self, funcname, func)

def __redis_commands__(self):
"""Store the list of available commands, for our redis instance."""
cmds = getattr(self, '__commands__', None)
if cmds is not None:
return cmds
try:
cmds = [c[0].upper().decode() for c in self.command()]
except AttributeError: # if encoded
cmds = [c[0].upper() for c in self.command()]
self.__commands__ = cmds
return cmds

def pipeline(self, transaction=True, shard_hint=None):
"""
Return a new pipeline object that can queue multiple commands for
Expand Down
13 changes: 0 additions & 13 deletions redis/commands/redismodules.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from json import JSONEncoder, JSONDecoder
from redis.exceptions import ModuleError


class RedisModuleCommands:
Expand All @@ -10,10 +9,6 @@ class RedisModuleCommands:
def json(self, encoder=JSONEncoder(), decoder=JSONDecoder()):
"""Access the json namespace, providing support for redis json.
"""
if 'JSON.SET' not in self.__commands__:
raise ModuleError("redisjson is not loaded in redis. "
"For more information visit "
"https://redisjson.io/")

from .json import JSON
jj = JSON(
Expand All @@ -25,10 +20,6 @@ def json(self, encoder=JSONEncoder(), decoder=JSONDecoder()):
def ft(self, index_name="idx"):
"""Access the search namespace, providing support for redis search.
"""
if 'FT.INFO' not in self.__commands__:
raise ModuleError("redisearch is not loaded in redis. "
"For more information visit "
"https://redisearch.io/")

from .search import Search
s = Search(client=self, index_name=index_name)
Expand All @@ -38,10 +29,6 @@ def ts(self):
"""Access the timeseries namespace, providing support for
redis timeseries data.
"""
if 'TS.INFO' not in self.__commands__:
raise ModuleError("reditimeseries is not loaded in redis. "
"For more information visit "
"https://redistimeseries.io/")

from .timeseries import TimeSeries
s = TimeSeries(client=self)
Expand Down
3 changes: 2 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ def pytest_addoption(parser):
def _get_info(redis_url):
client = redis.Redis.from_url(redis_url)
info = client.info()
if 'dping' in client.__commands__:
cmds = [c[0].upper().decode() for c in client.command()]
if 'dping' in cmds:
info["enterprise"] = True
else:
info["enterprise"] = False
Expand Down

0 comments on commit 4e9cc01

Please sign in to comment.