Full-featured job queue system with multiprocessing support for Linux
Project description
Queue Manager
A Python-based job queue system with per-job processes and signal variables.
Features
- Per-Job Processes: Each job runs in its own OS process for isolation
- Signal Variables: Jobs communicate via shared state protected by mutexes
- Registry Persistence: Job states and results are persisted to a registry
- Process Control: Start, stop, and delete jobs with graceful termination
- Progress Tracking: Real-time progress updates and status monitoring
- Error Handling: Comprehensive error handling and recovery mechanisms
Installation
pip install queuemgr
Quick Start
from queuemgr.queue.job_queue import JobQueue
from queuemgr.core.registry import JsonlRegistry
from queuemgr.jobs.base import QueueJobBase
from queuemgr.core.types import JobStatus
from queuemgr.core.ipc import update_job_state
class MyJob(QueueJobBase):
def execute(self):
# Your job logic here
for i in range(100):
update_job_state(
self._shared_state,
progress=i,
description=f"Processing item {i}"
)
def on_start(self):
update_job_state(self._shared_state, description="Job started")
def on_stop(self):
update_job_state(self._shared_state, description="Job stopped")
def on_end(self):
update_job_state(self._shared_state, description="Job completed")
def on_error(self, exc):
update_job_state(self._shared_state, description=f"Job failed: {exc}")
# Create queue and job
registry = JsonlRegistry("my_registry.jsonl")
queue = JobQueue(registry)
job = MyJob("my-job-1", {"param": "value"})
# Add and start job
queue.add_job(job)
queue.start_job("my-job-1")
# Monitor progress
status = queue.get_job_status("my-job-1")
print(f"Status: {status.status}, Progress: {status.progress}%")
Examples
See the examples/ directory for complete examples:
simple_job.py- Basic job creation and executionerror_handling_job.py- Error handling and recoveryprogress_job.py- Long-running job with progress updatesregistry_example.py- Registry functionality and job history
Development
# Install development dependencies
pip install -e ".[dev]"
# Run tests
pytest
# Run tests with coverage
pytest --cov=queuemgr
# Format code
black queuemgr tests
# Lint code
flake8 queuemgr tests
# Type check
mypy queuemgr
License
MIT License - see LICENSE file for details.
Author
Vasiliy Zdanovskiy - vasilyvz@gmail.com
vvz-queuemgr
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
queuemgr-1.0.17.tar.gz
(118.4 kB
view details)
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
queuemgr-1.0.17-py3-none-any.whl
(139.5 kB
view details)
File details
Details for the file queuemgr-1.0.17.tar.gz.
File metadata
- Download URL: queuemgr-1.0.17.tar.gz
- Upload date:
- Size: 118.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
839db8a5ebd09e69032d3f38b4e33f78136e4585c4c240ffa48041e96e990c55
|
|
| MD5 |
b21c95e97248f98487f168c0bf48555e
|
|
| BLAKE2b-256 |
55221dba23504774958ed02a63dba2fdeda849c52cbc94dd51fa448f7f8d9400
|
File details
Details for the file queuemgr-1.0.17-py3-none-any.whl.
File metadata
- Download URL: queuemgr-1.0.17-py3-none-any.whl
- Upload date:
- Size: 139.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
21d838d2689326373b9303c55eb7b1612871347a7696f102f3ecc69e196c2f86
|
|
| MD5 |
ac24d806052ef7d669c5405b74771b83
|
|
| BLAKE2b-256 |
f94b9fa91be08a83410075c7d4782f5e2586e8020ea491f7bbf4d840674b9b9c
|