Skip to main content

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 forkserver, 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 "forkserver"), 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 execution
  • error_handling_job.py - Error handling and recovery
  • progress_job.py - Long-running job with progress updates
  • registry_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.25

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for queuemgr 1.0.25
File Size Uploaded Provenance Actions
queuemgr-1.0.25.tar.gz 160.8 kB Without provenance Details for queuemgr-1.0.25.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for queuemgr 1.0.25
File Interpreter ABI Platform Actions
queuemgr-1.0.25-py3-none-any.whl Python 3 none any Details for queuemgr-1.0.25-py3-none-any.whl

Total release size: 303.9 kB

Release files / queuemgr-1.0.25.tar.gz

Download URL queuemgr-1.0.25.tar.gz
Size 160.8 kB
Tags Source
SHA-256 checksum
How to use checksums
def5d465af68ac7df4a649cfe01ff3bd4f46e6a83d52f91ba089f6de68585342
BLAKE2b-256 checksum
How to use checksums
12a80d169a991c4a1e7001c7a90b8d3a9da294bd91a533b8bee3afc58d343ef6
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.25-py3-none-any.whl

Download URL queuemgr-1.0.25-py3-none-any.whl
Size 143.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f9cd59e4e3a0a7c250c2f25f18d8928dadd32d22816d398e1b2c98add0b66cff
BLAKE2b-256 checksum
How to use checksums
76d9e53f831869d33c60503b52394d2b7ec56dcd9bb4e6309c85b5b66dd76138
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.4

Security for queuemgr 1.0.25

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page