Changes from self review

This commit is contained in:
Georges-Antoine Assi
2023-08-07 20:36:59 -04:00
parent 774d023943
commit a5c207cc80
2 changed files with 4 additions and 2 deletions

View File

@@ -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()

View File

@@ -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))