Skip to main content

A distributed messaging library similar to rq built on top of Redis

Project description

xq

A distributed queue system built on top of Redis

install

pip3 install -r requirements.txt

Use

Producer

import redis
from xq.queue import Queue

# connect to Redis
r = redis.Redis(host='localhost', port=6379)
# create queue
q = Queue(r, "test_queue")
# enqueue
q.enqueue("this is a message")

Consumer

import redis
from xq.queue import Queue

# connect to Redis
r = redis.Redis(host='localhost', port=6379)
# create queue
q = Queue(r, "test_queue")
# poll
messages = q.poll()
for message in messages:
    print(message.body)

Use Worker

import redis
from xq.queue import Queue
from xq.worker import Worker

# connect to Redis
r = redis.Redis(host='localhost', port=6379)
# create queue
q = Queue(r, "test_queue")
worker = Worker(q, process_message)
worker.run()

def process_message(message):
    print(message)

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

xqueue-0.0.1.tar.gz (4.6 kB view hashes)

Uploaded Source

Built Distribution

xqueue-0.0.1-py3-none-any.whl (4.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