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
Multiprocessing start method
queuemgr creates every job/manager process from its own local
multiprocessing context (see queuemgr/mp_context.py) instead of
relying on the process-wide default. That context defaults to spawn,
which does not fork the calling process and therefore does not duplicate
live threads, open sockets, or an in-flight asyncio event loop (e.g. a
running asyncio/hypercorn server) into the child.
queuemgr never calls multiprocessing.set_start_method, so it does not
read or mutate the global default start method used by your application or
other libraries. If you need a different method (for example because your
deployment environment cannot use "spawn"), set the
QUEUEMGR_MP_START_METHOD environment variable to "spawn",
"forkserver", or "fork" before queuemgr creates its first process.
export QUEUEMGR_MP_START_METHOD=forkserver
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
Metadata
Release files for queuemgr 1.0.23
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| queuemgr-1.0.23.tar.gz | 156.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| queuemgr-1.0.23-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 292.1 kB
Release files / queuemgr-1.0.23.tar.gz
| Download URL | queuemgr-1.0.23.tar.gz |
|---|---|
| Size | 156.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c8336a2c8e7c6ee1d63b403049033b7969ce79c58a2c1bae20a216d28c93b7c6
|
|
BLAKE2b-256 checksum How to use checksums |
51e133d4ae1c08de3e0238ccd6e2c5e3fbc7239b111d43ee439987b7b02416e3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.4
|
Release files / queuemgr-1.0.23-py3-none-any.whl
| Download URL | queuemgr-1.0.23-py3-none-any.whl |
|---|---|
| Size | 135.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f04c4cab9b9256b1dc6d0103d56240515e9e38523abe4e7d119ba7896a3e2c77
|
|
BLAKE2b-256 checksum How to use checksums |
24bca27f53103652bc5865b410c32b1d3ba9f165c8023a003123e18bd9f914ba
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.4
|