def ping(self): if self.r is not None: try: return self.r.ping() except (self.ConnectionError, AttributeError), err: logg.error("*** No Redis connection available: %s" % err) return False
def ping(self): if self.r is not None: try: return self.r.ping() except (self.ConnectionError, AttributeError), err: logg.error("no Redis connection available: %s" % err) return False
def __init__(self, *args, **kwargs): """ The RedisQueue is the default queue backend. The QueueBase methods are mapped to a Redis list; the redis-py module is required: https://github.com/andymccurdy/redis-py Redis is simple and fast, out of the box. The hiredis C library and python wrappers can be dropped into your install, to make it faster: https://github.com/pietern/hiredis-py To configure Redis, we pass the queue OPTIONS dict off wholesale to the python redis constructor -- Simply stick any Redis kwarg options you need into the OPTIONS setting. All the redis options can be furthermore specified in the RedisQueue constructor as a queue_options dict to override settings.py. """ super(RedisQueue, self).__init__(*args, **kwargs) try: import redis except ImportError: raise IOError("WTF: Can't import redis python module.") else: try: import hiredis except ImportError: logg.warn("can't import the `hiredis` package") logg.warn( "consider installing `hiredis` for native-speed access to a Redis queue" ) logg.warn( "you can see the difference even when running the tests --" ) logg.warn("-- it's a good move, trust me on that") self.r = redis.Redis(**self.queue_options) self.exceptions = (redis.exceptions.ConnectionError, redis.exceptions.DataError, redis.exceptions.InvalidResponse) try: self.r.ping() except self.exceptions, err: logg.error("connection to Redis server failed: %s" % err) self.r = None
def __init__(self, *args, **kwargs): """ The RedisQueue is the default queue backend. The QueueBase methods are mapped to a Redis list; the redis-py module is required: https://github.com/andymccurdy/redis-py Redis is simple and fast, out of the box. The hiredis C library and python wrappers can be dropped into your install, to make it faster: https://github.com/pietern/hiredis-py To configure Redis, we pass the queue OPTIONS dict off wholesale to the python redis constructor -- Simply stick any Redis kwarg options you need into the OPTIONS setting. All the redis options can be furthermore specified in the RedisQueue constructor as a queue_options dict to override settings.py. """ super(RedisQueue, self).__init__(*args, **kwargs) try: import redis except ImportError: raise IOError("WTF: Can't import redis python module.") else: try: import hiredis except ImportError: logg.warn("can't import the `hiredis` package") logg.warn("consider installing `hiredis` for native-speed access to a Redis queue") logg.warn("you can see the difference even when running the tests --") logg.warn("-- it's a good move, trust me on that") self.r = redis.Redis(**self.queue_options) self.exceptions = ( redis.exceptions.ConnectionError, redis.exceptions.DataError, redis.exceptions.InvalidResponse) try: self.r.ping() except self.exceptions, err: logg.error("connection to Redis server failed: %s" % err) self.r = None
def __init__(self, *args, **kwargs): """ The RedisQueue is the default queue backend. The QueueBase methods are mapped to a Redis list; the redis-py module is required: https://github.com/andymccurdy/redis-py Redis is simple and fast, out of the box. The hiredis C library and python wrappers can be dropped into your install, to make it faster: https://github.com/pietern/hiredis-py To configure Redis, we pass the queue OPTIONS dict off wholesale to the python redis constructor -- Simply stick any Redis kwarg options you need into the OPTIONS setting. All the redis options can be furthermore specified in the RedisQueue constructor as a queue_options dict to override settings.py. """ super(RedisQueue, self).__init__(*args, **kwargs) try: import redis except ImportError: raise IOError("WTF: Can't import redis python module.") else: try: import hiredis except ImportError: logg.warn("*** Can't import hiredis -- consider installing the 'hiredis' module for native-speed queue access.") self.r = redis.Redis(**self.queue_options) self.ConnectionError = redis.ConnectionError try: self.r.ping() except self.ConnectionError, err: logg.error("*** Redis connection failed: %s" % err) self.r = None