From d35de2272d31f0a8dcfb49c2ef3d54dc95b38a0b Mon Sep 17 00:00:00 2001 From: dHannasch Date: Sun, 15 Nov 2020 16:04:56 -0700 Subject: [PATCH] [Core] Allow redis.ResponseError instead of redis.AuthenticationError (#12024) * redis.ResponseError * there really is no way to make this look good, is there --- python/ray/tests/test_ray_init.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/python/ray/tests/test_ray_init.py b/python/ray/tests/test_ray_init.py index 5c42678d0..95bdd5c79 100644 --- a/python/ray/tests/test_ray_init.py +++ b/python/ray/tests/test_ray_init.py @@ -41,15 +41,20 @@ class TestRedisPassword: # We catch a generic Exception here in case someone later changes the # type of the exception. except Exception as ex: - if not isinstance(ex.__cause__, redis.AuthenticationError): + if not (isinstance(ex.__cause__, redis.AuthenticationError) + and "invalid password" in str(ex.__cause__)) and not ( + isinstance(ex, redis.ResponseError) and + "WRONGPASS invalid username-password pair" in str(ex)): raise # By contrast, we may be fairly confident the exact string # 'invalid password' won't go away, because redis-py simply wraps # the exact error from the Redis library. # https://github.com/andymccurdy/redis-py/blob/master/ # redis/connection.py#L132 - if "invalid password" not in str(ex.__cause__): - raise + # Except, apparently sometimes redis-py raises a completely + # different *type* of error for a bad password, + # redis.ResponseError, which is not even derived from + # redis.ConnectionError as redis.AuthenticationError is. # Check that we can connect to Redis using the provided password redis_client = redis.StrictRedis(