Skip to main content

Django Melnottam

⚠️ EXPERIMENTAL — This library is in early development. APIs may change without notice.

Bundle Django web workers and management-command workers behind a unified interface, using either Python 3.14+ subinterpreters (InterpreterPoolExecutor) or multiprocessing-based processes (ProcessPoolExecutor).

What it does

django-melnottam gives you one process manager for:

  • Web workers — ASGI/WSGI application servers powered by Hypercorn.
  • Command workers — any Django management command, run N times.
  • Two isolation models — subinterpreters for low overhead, processes for full memory isolation.
  • Graceful shutdown — queue-based stop signals, with process termination as a fallback.

Requirements

  • Python 3.14+
  • Django 6.0+
  • django-tasks-db >= 0.12.0
  • django-prodserver >= 2.4.0
  • hypercorn >= 0.18.0

Process backend note: It uses the fork start method so duplicated socket FDs are inherited by workers. On platforms without fork (e.g. Windows), web workers will not start; use the subinterpreter backend there.

Installation

pip install django-melnottam

Deployment with django-prodserver

If you use db_worker, add the task backend first:

INSTALLED_APPS = [
    # ...
    "django_tasks_db",
    "django_prodserver",
]

TASKS = {
    "default": {
        "BACKEND": "django_tasks_db.DatabaseBackend",
        "QUEUES": ["default"],
    }
}

Then configure the server:

For Multiprocessing

PRODUCTION_PROCESSES = {
            "web-with-command-workers": {
                "BACKEND": "django_melnottam.prodserver_backends.process.ProcessWorkerServer",
                "ARGS": {
                    "workers": 2,
                    "bind": "0.0.0.0:8000",
                    "app_path": "myapp.asgi:application",
                    "django_settings_module": "myapp.settings",
                    "command_workers": [
                        {
                            # Provided you have the django_tasks backend installed.
                            "command": "db_worker",
                            # Not doing this causes duplicate workers being loaded,
                            # So might as well be careful about it.
                            "options": {"reload": False},
                            "instances":1,
                        },
                    ],
                },
            },
        }

For Subinterpreters (which is still experimental as the subinterpreter eosystem is still changing)

PRODUCTION_PROCESSES = {
    "web-with-command-workers": {
        "BACKEND": "django_melnottam.prodserver_backends.subinterpreter.SubinterpreterWorkerServer",
        "ARGS": {
            "app_path": "myapp.wsgi:application",
            "django_settings_module": "myapp.settings",
            "workers": 4,
            "bind": "0.0.0.0:8000",
            "command_workers": [
                {
                    "command": "myapp.management.commands.send_emails",
                    "instances": 1,
                },
                {
                    "command": "django_tasks_db.management.commands.db_worker",
                    "options": {"queue_names": ["default"]},
                    "instances": 2,
                    "worker_factory": "django_melnottam.tasks.db_worker_factory",
                },
            ],
        },
    },
}

Run it with:

python manage.py prodserver web-with-command-workers

Use django_melnottam.prodserver_backends.process.ProcessWorkerServer for the process backend.

Command workers

Each entry in command_workers describes one management command:

  • command — explicit dotted path to the command module.
  • args — positional/CLI-style arguments (optional).
  • options — keyword options passed to call_command (optional).
  • instances — number of copies to run (default 1).
  • worker_factory — optional dotted path to a factory returning a stoppable object.

Without worker_factory, the worker runs call_command(...) and must exit on its own. This is ideal for one-shot commands.

For long-running commands like db_worker, provide a factory. The bundled django_melnottam.tasks.db_worker_factory returns a django_tasks_db worker that can be stopped through the shutdown queue.

The subinterpreter backend cannot force-stop a running command, so long-running commands there need a factory. The process backend does not require one: it terminates any remaining workers with ProcessPoolExecutor.terminate_workers().

CLI

django-melnottam-cli <application> [options]
  • -w, --workers — number of web workers (default 2)
  • -c, --command-workers — JSON list of command specs (default [])
  • -b, --bind — bind address (default 0.0.0.0:9001)
  • -s, --settings — Django settings module
  • -p, --pool — interpreter or process (default interpreter)
  • -v, --verbose — debug logging

Example:

django-melnottam-cli myapp.wsgi:application \
  --workers 4 \
  --bind 0.0.0.0:8000 \
  --settings myapp.settings \
  --command-workers '[{"command": "myapp.management.commands.send_emails", "instances": 1}]'

Programmatic usage

from django_melnottam.application import run_application
from django_melnottam.backends import PoolType
from django_melnottam.workers import CommandSpec

run_application(
    app_path="myapp.wsgi:application",
    workers=4,
    bind="0.0.0.0:8000",
    django_settings_module="myapp.settings",
    pool_type=PoolType.INTERPRETER,  # or PoolType.PROCESS
    command_workers=[
        CommandSpec(
            command="myapp.management.commands.send_emails",
            instances=1,
        ),
        CommandSpec(
            command="django_tasks_db.management.commands.db_worker",
            options={"queue_names": ["default"]},
            instances=2,
            worker_factory="django_melnottam.tasks.db_worker_factory",
        ),
    ],
)

LLM Disclosure

The project idea and design are the author's. LLMs assisted with scaffolding boilerplate, drafting tests, and writing documentation (including this README). All generated output was reviewed and edited.

Metadata

Release files for django-melnottam 0.1.2

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

Source distribution (sdist)

Source distribution for django-melnottam 0.1.2
File Size Uploaded Provenance Actions
django_melnottam-0.1.2.tar.gz 26.8 kB With provenance Details for django_melnottam-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for django-melnottam 0.1.2
File Interpreter ABI Platform Actions
django_melnottam-0.1.2-py3-none-any.whl Python 3 none any Details for django_melnottam-0.1.2-py3-none-any.whl

Total release size: 48.6 kB

Release files / django_melnottam-0.1.2.tar.gz

Download URL django_melnottam-0.1.2.tar.gz
Size 26.8 kB
Tags Source
SHA-256 checksum
How to use checksums
22f316eec310b6d1bc1c44fa6bc294d2a9e6aa7934ee3f3ee4ca8a035253b642
BLAKE2b-256 checksum
How to use checksums
6e8f335b1482aee8ae31cc278dbc939cd10263b0dd0511d912c7ce1d5fdfb8ce
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.

Transparency log

Release files / django_melnottam-0.1.2-py3-none-any.whl

Download URL django_melnottam-0.1.2-py3-none-any.whl
Size 21.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
92dd5b911d663103f00eeeff3ebeb279dae8913e100652619e8158f1c3a325e7
BLAKE2b-256 checksum
How to use checksums
9264f29035a82582580f01b0966b5070457a1c3e538bb1d72291cd87e1bc2428
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.

Transparency log

Security for django-melnottam 0.1.2

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for django_melnottam-0.1.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.

Transparency log

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