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 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 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.22

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.22
File Size Uploaded
queuemgr-1.0.22.tar.gz 152.6 kB Details

Built distribution (wheel)

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

Total release size: 282.2 kB

Release files / queuemgr-1.0.22.tar.gz

Download URL queuemgr-1.0.22.tar.gz
Size 152.6 kB
Tags Source
SHA-256 checksum
How to use checksums
ccf6a7e519439e146176bd3b2b80c547f73a0c2c165a5ce7e5213ab2c3c8d284
BLAKE2b-256 checksum
How to use checksums
8ca7c8f0b6592ca988f038cb00e41dbcc1254d1423eda2be9c8584f4a858eb58
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.22-py3-none-any.whl

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

Release history Release notifications | RSS feed

1.0.23

2 release files

This release

1.0.22 This release

2 release files

1.0.19

2 release files

1.0.17

2 release files

1.0.16

2 release files

1.0.15

2 release files

1.0.13

2 release files

1.0.12

2 release files

1.0.11

2 release files

1.0.10

2 release files

1.0.9

2 release files

1.0.8

2 release files

1.0.7

2 release files

1.0.6

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.0

2 release files

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