xq
A distributed queue system built on top of Redis with cron-based scheduling support
XQ is a lightweight distributed task queue that allows you to:
- Schedule tasks to run at specific times using cron expressions
- Run tasks immediately or on a recurring schedule
- Poll tasks based on their scheduled execution time
- Manage queues and tasks through code or a web interface
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 a task to run immediately
q.enqueue("this is a one-time message")
# enqueue a task with cron scheduling (runs every 5 minutes)
q.enqueue("this is a recurring message", cron_expression="*/5 * * * *")
# enqueue a task to run at midnight every day
q.enqueue("this runs at midnight", cron_expression="0 0 * * *")
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 for tasks that are ready to be executed
messages = q.poll()
for message in messages:
print(f"Processing message: {message.body}")
# For recurring tasks (with cron expressions), they will be
# automatically re-enqueued for their next scheduled run
Use Worker
import redis
from xq.queue import Queue
from xq.worker import Worker
def process_message(message):
print(f"Worker processing: {message.body}")
# Your task processing logic here
# connect to Redis
r = redis.Redis(host='localhost', port=6379)
# create queue
q = Queue(r, "test_queue")
# create and run worker
worker = Worker(q, process_message)
# worker will continuously poll for tasks based on their scheduled time
worker.run()
Scheduling with Cron Expressions
XQ supports cron expressions for scheduling recurring tasks:
| Cron Expression | Description |
|---|---|
* * * * * |
Run every minute |
*/5 * * * * |
Run every 5 minutes |
0 * * * * |
Run at the start of every hour |
0 0 * * * |
Run once a day at midnight |
0 0 * * 0 |
Run once a week on Sunday at midnight |
0 0 1 * * |
Run once a month on the 1st at midnight |
The cron format consists of five fields: minute hour day-of-month month day-of-week
Web UI & API Server
XQ includes a web interface and API for managing queues and messages with built-in cron expression interpretation.
Setup
- Install the required dependencies:
pip install -r server/requirements.txt
-
Make sure Redis is running on localhost:6379
-
Start the server:
python server/api.py
- Open your browser and navigate to http://localhost:8000
Features
- View all available queues
- Create new queues
- View messages in a queue with human-readable cron interpretations
- Add new messages with optional cron scheduling
- Delete messages from a queue
- Poll messages from a queue
API Endpoints
GET /api/queues- List all available queuesGET /api/queues/{queue_name}/messages- List all messages in a queuePOST /api/queues/{queue_name}/messages- Add a new message to a queueDELETE /api/queues/{queue_name}/messages/{message_id}- Delete a message from a queuePOST /api/queues/{queue_name}/poll- Poll messages from a queue
Metadata
Release files for xqueue 0.2.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| xqueue-0.2.3.tar.gz | 17.8 kB | Without provenance | Details for xqueue-0.2.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| xqueue-0.2.3-py3-none-any.whl | Python 3 | none | any | Details for xqueue-0.2.3-py3-none-any.whl |
Total release size: 35.6 kB
Release files / xqueue-0.2.3.tar.gz
| Download URL | xqueue-0.2.3.tar.gz |
|---|---|
| Size | 17.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8970819bf7232533c50f21754b7b35bf20d1ecaa3d700028966ba46f4574a235
|
|
BLAKE2b-256 checksum How to use checksums |
60a0bd561e7bbbfb9737f6f69780053e6ed6683f10343a7737669b0bfceab810
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.3
|
Release files / xqueue-0.2.3-py3-none-any.whl
| Download URL | xqueue-0.2.3-py3-none-any.whl |
|---|---|
| Size | 17.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c6a4ebd302995542dee20ecad1c29e8116122f4ef1f62cf1a38727742eed053b
|
|
BLAKE2b-256 checksum How to use checksums |
5106a4a89834be17edcc33337116228f8a9cd6651e4b5f8cc7acf319fc4327d0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.3
|
Security for xqueue 0.2.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.