Skip to content

Commit

Permalink
Don't print Redis connection warning in ray.init(). (#8475)
Browse files Browse the repository at this point in the history
  • Loading branch information
robertnishihara committed May 18, 2020
1 parent b6c4f45 commit 2cff471
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions python/ray/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -527,10 +527,7 @@ def preexec_fn():
use_tmux=use_tmux)


def wait_for_redis_to_start(redis_ip_address,
redis_port,
password=None,
num_retries=5):
def wait_for_redis_to_start(redis_ip_address, redis_port, password=None):
"""Wait for a Redis server to be available.
This is accomplished by creating a Redis client and sending a random
Expand All @@ -540,17 +537,16 @@ def wait_for_redis_to_start(redis_ip_address,
redis_ip_address (str): The IP address of the redis server.
redis_port (int): The port of the redis server.
password (str): The password of the redis server.
num_retries (int): The number of times to try connecting with redis.
The client will sleep for one second between attempts.
Raises:
Exception: An exception is raised if we could not connect with Redis.
"""
redis_client = redis.StrictRedis(
host=redis_ip_address, port=redis_port, password=password)
# Wait for the Redis server to start.
counter = 0
while counter < num_retries:
num_retries = 12
delay = 0.001
for _ in range(num_retries):
try:
# Run some random command and see if it worked.
logger.debug(
Expand All @@ -559,12 +555,11 @@ def wait_for_redis_to_start(redis_ip_address,
redis_client.client_list()
except redis.ConnectionError:
# Wait a little bit.
time.sleep(1)
logger.info("Failed to connect to the redis server, retrying.")
counter += 1
time.sleep(delay)
delay *= 2
else:
break
if counter == num_retries:
else:
raise RuntimeError("Unable to connect to Redis. If the Redis instance "
"is on a different machine, check that your "
"firewall is configured properly.")
Expand Down

0 comments on commit 2cff471

Please sign in to comment.