StudE-Backend/stude/wait_for_redis.py

15 lines
361 B
Python
Raw Normal View History

import time
import os
import redis
REDIS_HOST = os.getenv('REDIS_HOST', 'localhost')
REDIS_PORT = os.getenv('REDIS_PORT', 6379)
if __name__ == '__main__':
while True:
try:
redis.Redis(host=REDIS_HOST, port=REDIS_PORT)
print('Redis is up!')
break
except redis.ConnectionError:
time.sleep(0.1)