Skip to main content

Priority message queue with Redis

Project description

https://circleci.com/gh/okomestudio/pyrediq/tree/development.svg?style=shield https://coveralls.io/repos/github/okomestudio/pyrediq/badge.svg?branch=development

pyrediq

pyrediq (py-re-ddi-ck) is a Python (2.7) library providing an implementation of priority messaging queue using Redis. The message payload is serialized by MessagePack.

pyrediq is licensed under the MIT License (MIT).

Basic Usage

import redis
from pyrediq import PriorityQueue, QueueEmpty

redis_conn = redis.StrictRedis()

# create a queue
queue = PriorityQueue('myqueue', redis_conn)

# enqueue a message to the queue
queue.put({'mykey': 'myvalue'}, priority=-1)

# create a consumer
with queue.consumer() as consumer:
    try:
        msg = consumer.get(block=False)
    except QueueEmpty:
        raise

    success = do_task(msg.payload)

    # the message is either acked or rejected after task is done.
    # a rejected message can optionally be requeued
    if success:
        consumer.ack(msg)
    else:
        consumer.reject(msg, requeue=True)

queue.close()

To remove all message from a queue and remove the queue itself, run PriorityQueue.purge method:

queue.purge()

Installation

To install pyrediq using pip, run this command on the shell:

pip install pyrediq

To use pyrediq, Redis needs to be installed and running on the computer. For example, on a Debian box, running this command should suffice:

sudo apt-get install redis-server

Consult the official Redis distribution site for the install procedure.

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

pyrediq-0.3.4.tar.gz (8.3 kB view details)

Uploaded Source

File details

Details for the file pyrediq-0.3.4.tar.gz.

File metadata

  • Download URL: pyrediq-0.3.4.tar.gz
  • Upload date:
  • Size: 8.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pyrediq-0.3.4.tar.gz
Algorithm Hash digest
SHA256 30f2df5d58894fcab0fab2f35f1f81852c3eb489e1480d54a73e737510154240
MD5 f312ca960f6a59214273baf5ba53e1fc
BLAKE2b-256 9a43ace20a8e4f5dbb1d8faac43996abd244d3f4b11921e316155731e58b1f09

See more details on using hashes here.

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