def is_redis_available(): try: rs.get(None) # getting None returns None or throws an exception except (redis.exceptions.ConnectionError, redis.exceptions.BusyLoadingError): return False return True