Skip to main content

A distributed queue based on Redis.

Project description

A distributed queue based on Redis

Installation

pip install redque

Example

import time
import random
import threading
import redis
import redque


def productor(redis_conn):
    other_queue = redque.Queue(redis_conn, "__test", "bp__test")

    for _ in range(100):
        other_queue.push("e_{0}".format(random.randint(1, 100)))
        time.sleep(0.1)


if __name__ == "__main__":
    pool = redis.ConnectionPool(
        host="127.0.0.1",
        port=6379,
        password="123456"
    )

    queue = redque.Queue(
        redis.Redis(connection_pool=pool),
        "__test",
        "bp__test"
    )
    queue.clear(True)

    # non-blocking
    for _ in range(100):
        queue.push(random.randint(1, 100))

    queue.process(lambda x: (print(x), True), False)

    # blocking
    t = threading.Thread(target=productor,
                        args=(redis.Redis(connection_pool=pool),))
    t.start()

    queue.process(lambda x: (print(x), True), timeout=3)

    t.join()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

redque-0.1.0.tar.gz (2.6 kB view hashes)

Uploaded Source

Built Distribution

redque-0.1.0-py3-none-any.whl (6.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page