def put(self, value): """Put string (serialized json, for example) value to the tail of the redis list. :param value: data to store in queue""" key = get_key(self.qname) yield from self._conn.rpush(key, [value])
def get(self): """Dequeue data from head of list, if redis list is empty, BLPOP command waits for new data. :return: ``str`` serialized vdata fetched from redis list """ key = get_key(self.qname) data = yield from self._conn.blpop([key,], 0) return data.value
def size(self): """Coroutine to check current size of queue. :return: ``int`` size of the queue""" size = yield from self._conn.llen(get_key(self.qname)) return size