A flexible message queue system with SQLite backend and Flask API
Project description
tc-queue-system
A simple message queue system with SQLite backend and optional Flask API.
Installation
# Basic (module only, no Flask required)
pip install tc-queue-system
# With Flask API server
pip install tc-queue-system[server]
Features
- SQLite Backend - No external dependencies, works anywhere
- Module Usage - Use directly in Python code (no Flask required)
- REST API Server - Optional Flask server with basic auth
- Priority Queues - Higher priority messages processed first
- Message Acknowledgment - Ack/Nack support for reliable processing
- Thread-Safe - Singleton pattern with thread-safe operations
Quick Start
As Module (No Flask Required)
from tc_queue_system import QueueService
# Get singleton instance
qs = QueueService()
# Create queue
qs.create_queue('tasks')
# Publish message
msg_id = qs.publish('tasks', {'action': 'send_email', 'to': 'user@example.com'})
print(f'Published: {msg_id}')
# Publish with priority (higher = processed first)
qs.publish('tasks', {'action': 'urgent'}, priority=10)
# Consume message
msg = qs.consume('tasks')
if msg:
print(f'Processing: {msg["data"]}')
qs.ack(msg['id']) # Acknowledge completion
# or qs.nack(msg['id']) to requeue
# Get stats
print(qs.stats())
# {'queues': 1, 'pending': 0, 'processing': 0, 'timestamp': '...'}
As REST API Server
# Start server (requires Flask)
pip install tc-queue-system[server]
python -m tc_queue_system.service --port 8090
# Or use CLI after install
tc-queue --port 8090
# Or start from code
from tc_queue_system import run_server
run_server(port=8090, auth_user='admin', auth_pass='secret')
API Endpoints
All endpoints require Basic Auth (default: admin/123).
| Method | Endpoint | Description |
|---|---|---|
| GET | / |
Service info |
| GET | /stats |
Overall statistics |
| GET | /queues |
List all queues |
| POST | /queue/<name> |
Create queue |
| GET | /queue/<name> |
Get queue info |
| DELETE | /queue/<name> |
Delete queue |
| POST | /queue/<name>/publish |
Publish message (JSON body) |
| POST | /queue/<name>/consume |
Consume one message |
| POST | /queue/<name>/purge |
Purge all messages |
| GET | /queue/<name>/size |
Get queue size |
| POST | /message/<id>/ack |
Acknowledge message |
| POST | /message/<id>/nack |
Requeue message |
API Examples
# Set auth
AUTH="-u admin:123"
# Create queue
curl $AUTH -X POST http://localhost:8090/queue/emails
# Publish message
curl $AUTH -X POST http://localhost:8090/queue/emails/publish \
-H "Content-Type: application/json" \
-d '{"to": "user@example.com", "subject": "Hello"}'
# Publish with priority
curl $AUTH -X POST http://localhost:8090/queue/emails/publish \
-H "Content-Type: application/json" \
-d '{"to": "vip@example.com", "_priority": 10}'
# Consume message
curl $AUTH -X POST http://localhost:8090/queue/emails/consume
# Ack message
curl $AUTH -X POST http://localhost:8090/message/1/ack
# Get stats
curl $AUTH http://localhost:8090/stats
Configuration
Environment Variables
# Auth credentials (optional, defaults to admin/123)
export QUEUE_AUTH_USER=myuser
export QUEUE_AUTH_PASS=mypassword
Custom Database Path
from tc_queue_system.service import QueueService
# Use custom database path
qs = QueueService(db_path='/path/to/queue.db')
QueueService API
from tc_queue_system import QueueService
qs = QueueService()
# Queue operations
qs.create_queue(name: str) -> bool
qs.delete_queue(name: str) -> bool
qs.list_queues() -> List[Dict]
qs.get_queue(name: str) -> Dict
# Message operations
qs.publish(queue: str, data: Dict, priority: int = 0) -> int
qs.consume(queue: str) -> Optional[Dict]
qs.ack(message_id: int) -> bool
qs.nack(message_id: int) -> bool
qs.purge(queue: str) -> int
qs.size(queue: str) -> int
# Stats
qs.stats() -> Dict
License
MIT License - see LICENSE for details.
Links
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tc_queue_system-1.0.0.tar.gz.
File metadata
- Download URL: tc_queue_system-1.0.0.tar.gz
- Upload date:
- Size: 12.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a987b68e2168d2c27e06c56a45a54f97a49d648dff02f555a9ad0cf9cd513850
|
|
| MD5 |
bec9bf6f699c6f448ebca8c78f859f5b
|
|
| BLAKE2b-256 |
c112bc06b61a77968a6a1e7baa73c4ba9e8eb8caadbe11df0cfbc7e91ebb2d9b
|
Provenance
The following attestation bundles were made for tc_queue_system-1.0.0.tar.gz:
Publisher:
publish.yml on task-circuit/tc-queue-system
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tc_queue_system-1.0.0.tar.gz -
Subject digest:
a987b68e2168d2c27e06c56a45a54f97a49d648dff02f555a9ad0cf9cd513850 - Sigstore transparency entry: 836394751
- Sigstore integration time:
-
Permalink:
task-circuit/tc-queue-system@27fab9b0cbce1d902a642b48118d93e2c450e70c -
Branch / Tag:
refs/heads/main - Owner: https://github.com/task-circuit
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@27fab9b0cbce1d902a642b48118d93e2c450e70c -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file tc_queue_system-1.0.0-py3-none-any.whl.
File metadata
- Download URL: tc_queue_system-1.0.0-py3-none-any.whl
- Upload date:
- Size: 9.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3c612c44ede003b91c9b9ab83d2cc76bb263e8ad14deac39e3ffb05881dc4295
|
|
| MD5 |
ed8cb016ff92a32f76e40022945bce15
|
|
| BLAKE2b-256 |
5cb6fc9eeab804e31d6872403ab17eb59f7336cbdd12dcae1cd891dd82463281
|
Provenance
The following attestation bundles were made for tc_queue_system-1.0.0-py3-none-any.whl:
Publisher:
publish.yml on task-circuit/tc-queue-system
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tc_queue_system-1.0.0-py3-none-any.whl -
Subject digest:
3c612c44ede003b91c9b9ab83d2cc76bb263e8ad14deac39e3ffb05881dc4295 - Sigstore transparency entry: 836394752
- Sigstore integration time:
-
Permalink:
task-circuit/tc-queue-system@27fab9b0cbce1d902a642b48118d93e2c450e70c -
Branch / Tag:
refs/heads/main - Owner: https://github.com/task-circuit
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@27fab9b0cbce1d902a642b48118d93e2c450e70c -
Trigger Event:
workflow_dispatch
-
Statement type: