diff --git a/backend/utils/cache.py b/backend/utils/cache.py index 5b277f59e..e83cd6fa2 100644 --- a/backend/utils/cache.py +++ b/backend/utils/cache.py @@ -2,7 +2,7 @@ from redis import Redis, ConnectionError from config import REDIS_HOST, REDIS_PORT -redis_client = Redis(host=REDIS_HOST, port=REDIS_PORT, db=0) # decode_responses +redis_client = Redis(host=REDIS_HOST, port=REDIS_PORT, db=0) redis_url = f"redis://{REDIS_HOST}:{REDIS_PORT}" try: @@ -37,5 +37,6 @@ class FallbackCache: return repr(self) +# A seperate client that auto-decodes responses is needed _cache_client = Redis(host=REDIS_HOST, port=REDIS_PORT, db=0, decode_responses=True) cache = _cache_client if redis_connectable else FallbackCache() diff --git a/backend/worker.py b/backend/worker.py index c0280fc70..5fc4b08c2 100755 --- a/backend/worker.py +++ b/backend/worker.py @@ -6,8 +6,9 @@ from utils.cache import redis_client, redis_connectable listen = ["high", "default", "low"] if __name__ == "__main__": + # Exit if Redis is not connectable if not redis_connectable: - sys.exit(2) + sys.exit(0) with Connection(redis_client): worker = Worker(map(Queue, listen))