रेडिस के पिंग cmd का उपयोग करें:
import redis
from redis import ConnectionError
import logging
logging.basicConfig()
logger = logging.getLogger('redis')
rs = redis.Redis("localhost")
try:
rs.ping()
except ConnectionError:
logger.error("Redis isn't running. try `/etc/init.d/redis-server restart`")
exit(0)
नमूना आउटपुट:
ERROR:redis:Redis isn't running. try `/etc/init.d/redis-server restart`