Skip to content
This repository has been archived by the owner on Jan 28, 2020. It is now read-only.

Commit

Permalink
Added handling for Redis ResponseError.
Browse files Browse the repository at this point in the history
In addition to failure to connect, we could
connect then fail to provide a required password.
  • Loading branch information
ShawnMilo committed Aug 13, 2015
1 parent d812880 commit 6f17152
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions status/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@
from elasticsearch import Elasticsearch, ConnectionError as ESConnectionError
from kombu.utils.url import _parse_url as parse_redis_url
from psycopg2 import connect, OperationalError
from redis import StrictRedis, ConnectionError as RedisConnectionError
from redis import (
StrictRedis,
ConnectionError as RedisConnectionError,
ResponseError as RedisResponseError,
)

log = logging.getLogger(__name__)

Expand Down Expand Up @@ -75,8 +79,12 @@ def get_redis_info():
rdb = StrictRedis(
host=host, port=port, db=db, socket_timeout=TIMEOUT_SECONDS)
info = rdb.info()
except (RedisConnectionError, TypeError):
except (RedisConnectionError, TypeError) as ex:
log.error("Error making Redis connection: %s", ex.args)
return {"status": DOWN}
except RedisResponseError as ex:
log.error("Bad Redis response: %s", ex.args)
return {"status": DOWN, "message": "auth error"}
micro = (datetime.now() - start).microseconds
del rdb # the redis package does not support Redis's QUIT.
ret = {
Expand Down

0 comments on commit 6f17152

Please sign in to comment.