Exemplo n.º 1
0
    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])
Exemplo n.º 2
0
    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
Exemplo n.º 3
0
    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