Skip to content

Commit

Permalink
connection: remove a workaround for obsolete Redis version
Browse files Browse the repository at this point in the history
Signed-off-by: Mikhail Koviazin <[email protected]>
  • Loading branch information
mkmkme committed May 28, 2024
1 parent a0e20ea commit 506b789
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 22 deletions.
12 changes: 1 addition & 11 deletions valkey/asyncio/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
from valkey.credentials import CredentialProvider, UsernamePasswordCredentialProvider
from valkey.exceptions import (
AuthenticationError,
AuthenticationWrongNumberOfArgsError,
ConnectionError,
DataError,
ResponseError,
Expand Down Expand Up @@ -382,16 +381,7 @@ async def on_connect(self) -> None:
# to check the health prior to the AUTH
elif auth_args:
await self.send_command("AUTH", *auth_args, check_health=False)

try:
auth_response = await self.read_response()
except AuthenticationWrongNumberOfArgsError:
# a username and password were specified but the Valkey
# server seems to be < 6.0.0 which expects a single password
# arg. retry auth with just the password.
# https://github.com/andymccurdy/redis-py/issues/1274
await self.send_command("AUTH", auth_args[-1], check_health=False)
auth_response = await self.read_response()
auth_response = await self.read_response()

if str_if_bytes(auth_response) != "OK":
raise AuthenticationError("Invalid Username or Password")
Expand Down
12 changes: 1 addition & 11 deletions valkey/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
from .credentials import CredentialProvider, UsernamePasswordCredentialProvider
from .exceptions import (
AuthenticationError,
AuthenticationWrongNumberOfArgsError,
ChildDeadlockedError,
ConnectionError,
DataError,
Expand Down Expand Up @@ -376,16 +375,7 @@ def on_connect(self):
# avoid checking health here -- PING will fail if we try
# to check the health prior to the AUTH
self.send_command("AUTH", *auth_args, check_health=False)

try:
auth_response = self.read_response()
except AuthenticationWrongNumberOfArgsError:
# a username and password were specified but the Valkey
# server seems to be < 6.0.0 which expects a single password
# arg. retry auth with just the password.
# https://github.com/andymccurdy/redis-py/issues/1274
self.send_command("AUTH", auth_args[-1], check_health=False)
auth_response = self.read_response()
auth_response = self.read_response()

if str_if_bytes(auth_response) != "OK":
raise AuthenticationError("Invalid Username or Password")
Expand Down

0 comments on commit 506b789

Please sign in to comment.