django_prodserver.backends package

Subpackages

Submodules

django_prodserver.backends.base module

class django_prodserver.backends.base.BaseProcessBackend(**server_args: Any)[source]

Bases: object

Base class to configure an individual process backend.

You are required to override start_server in the subclass. Most backends should subclass BaseServerBackend (for web/ASGI/WSGI servers) or BaseWorkerBackend (for background task workers) rather than this class directly so the server and worker management commands can tell the two apart.

{

“BACKEND”: “django_prodserver.backends.servers.gunicorn.GunicornServer”, “ARGS”: {“bind”: “0.0.0.0:8111”}

}

prep_server_args() list[str][source]

Here we customisation of the arguments passed to the server process.

Typically this is where fixed arguments are inserted into the args

start_server(*args: str) None[source]

Function is called to start the process directly.

This must be implemented in the subclass

class django_prodserver.backends.base.BaseServerBackend(**server_args: Any)[source]

Bases: BaseProcessBackend

Base class for web server backends (WSGI / ASGI).

Backends that subclass this are runnable via python manage.py server.

class django_prodserver.backends.base.BaseWorkerBackend(**server_args: Any)[source]

Bases: BaseProcessBackend

Base class for background task worker backends.

Backends that subclass this are runnable via python manage.py worker.

django_prodserver.backends.celery module

Deprecated; see django_prodserver.backends.workers.celery.

class django_prodserver.backends.celery.CeleryBeat(**server_config: Any)[source]

Bases: CeleryWorker

Backend to start a celery beat process.

start_server(*args: str) None[source]

Start Celery beat via the beat subcommand on the Celery app.

class django_prodserver.backends.celery.CeleryWorker(**server_config: Any)[source]

Bases: BaseWorkerBackend

Backend to start a celery worker.

start_server(*args: str) None[source]

Start Celery Worker via the worker subcommand on the Celery app.

django_prodserver.backends.daphne module

Deprecated; see django_prodserver.backends.dev.daphne.

class django_prodserver.backends.daphne.DaphneRunserver(**server_args: Any)[source]

Bases: BaseRunserverBackend

ASGI development server backend driving daphne.Server directly.

Mirrors the behaviour of channels-runserver 3.0.5 (which Channels 4.x no longer ships) by calling out to Daphne’s public API and Django’s autoreload / system-check utilities, rather than going through any management command.

Configured entirely through the standard ARGS dict, with key names that match Daphne’s CLI flags 1:1:

{
    "BACKEND": "django_prodserver.backends.dev.daphne.DaphneRunserver",
    "ARGS": {
        "addrport": "127.0.0.1:8000",
        "ipv6": False,
        "noreload": False,
        "nostatic": False,
        "insecure": False,
        "http_timeout": None,
        "websocket_handshake_timeout": 5,
        # Full Daphne CLI surface also accepted:
        "unix_socket": None,
        "fd": None,
        "endpoints": [],
        "verbosity": 1,
        "root_path": "",
        "proxy_headers": False,
        "ping_interval": 20,
        "ping_timeout": 30,
        "application_close_timeout": 10,
        "websocket_timeout": 86400,
        "websocket_connect_timeout": 20,
        "request_buffer_size": 8192,
        "server_name": "daphne",
        "access_log": None,
    },
}

All keys are optional. nothreading is accepted for parity with DjangoRunserver but ignored — Daphne is single-reactor by design.

get_application() Any[source]

Resolve the ASGI app and conditionally wrap with ASGIStaticFilesHandler.

server_kind: str = 'ASGI development'

django_prodserver.backends.django_q2 module

Deprecated; see django_prodserver.backends.workers.django_q2.

class django_prodserver.backends.django_q2.DjangoQ2Worker(**server_args: Any)[source]

Bases: BaseWorkerBackend

Backend to start a Django-Q2 task queue worker.

prep_server_args() list[str][source]

Prepare arguments for qcluster command.

Returns:

List of formatted command line arguments for qcluster.

Note:

Most Django-Q2 configuration should be done through the Q_CLUSTER setting in Django settings. The ARGS configuration in PRODUCTION_PROCESSES is primarily for runtime options like verbosity and cluster naming.

start_server(*args: str) None[source]

Start Django-Q2 cluster using qcluster management command.

Args:
*args: Command line arguments to pass to the qcluster command.

Common arguments include: - –verbosity: Control logging verbosity (0-3) - –cluster-name: Specify cluster name - –settings: Override Django settings module

django_prodserver.backends.django_runserver module

Deprecated; see django_prodserver.backends.dev.django_runserver.

class django_prodserver.backends.django_runserver.DjangoRunserver(**server_args: Any)[source]

Bases: BaseRunserverBackend

Development server backend mirroring django.core.management.commands.runserver.

Configured entirely through the standard ARGS dict, with key names that match runserver’s CLI flags 1:1:

{
    "BACKEND": (
        "django_prodserver.backends.dev.django_runserver.DjangoRunserver"
    ),
    "ARGS": {
        "addrport": "127.0.0.1:8000",
        "ipv6": False,
        "noreload": False,
        "nothreading": False,
        "nostatic": False,
        "insecure": False,
    },
}

All keys are optional. Behaviour mirrors runserver’s inner_run by calling out to Django’s existing utilities (BaseCommand.check, basehttp.run, autoreload.run_with_reloader, StaticFilesHandler) rather than reimplementing them.

get_handler() Any[source]

Mirror runserver.get_handler + the staticfiles override.

server_kind: str = 'development'

django_prodserver.backends.django_tasks module

Deprecated; see django_prodserver.backends.workers.django_tasks.

class django_prodserver.backends.django_tasks.DjangoTasksWorker(**server_args: Any)[source]

Bases: BaseWorkerBackend

Backend to start a django task db worker.

start_server(*args: str) None[source]

Call django-tasks management command.

django_prodserver.backends.granian module

Deprecated; see django_prodserver.backends.servers.granian.

class django_prodserver.backends.granian.GranianASGIServer(**server_args: Any)[source]

Bases: GranianServerBase

Granian ASGI Server Backend.

This backend uses Granian’s ASGI interface to serve Django ASGI applications. Granian is a Rust-based HTTP server with excellent performance characteristics.

Example configuration:
{

“BACKEND”: “django_prodserver.backends.servers.granian.GranianASGIServer”, “ARGS”: {

“address”: “0.0.0.0”, “port”: “8000”, “workers”: “4”, “blocking_threads”: “1”,

}

}

class django_prodserver.backends.granian.GranianServerBase(**server_args: Any)[source]

Bases: BaseServerBackend

Base class for Granian server backends.

Provides common functionality for both ASGI and WSGI Granian servers, including argument parsing and server configuration.

start_server(*args: str) None[source]

Start the Granian server.

class django_prodserver.backends.granian.GranianWSGIServer(**server_args: Any)[source]

Bases: GranianServerBase

Granian WSGI Server Backend.

This backend uses Granian’s WSGI interface to serve Django WSGI applications. Granian is a Rust-based HTTP server with excellent performance characteristics.

Example configuration:
{

“BACKEND”: “django_prodserver.backends.servers.granian.GranianWSGIServer”, “ARGS”: {

“address”: “0.0.0.0”, “port”: “8000”, “workers”: “4”, “blocking_threads”: “2”,

}

}

django_prodserver.backends.gunicorn module

django_prodserver.backends.uvicorn module

Deprecated; see django_prodserver.backends.servers.uvicorn.

class django_prodserver.backends.uvicorn.UvicornServer(**server_args: Any)[source]

Bases: BaseServerBackend

Uvicorn ASGIServer Backend.

This bypasses any Django handling of the command and sends all arguments straight to uvicorn.

prep_server_args() list[str][source]

Prepare the server args.

start_server(*args: str) None[source]

Start the server.

class django_prodserver.backends.uvicorn.UvicornWSGIServer(**server_args: Any)[source]

Bases: BaseServerBackend

Uvicorn WSGIServer Backend.

This bypasses any Django handling of the command and sends all arguments straight to uvicorn.

prep_server_args() list[str][source]

Prepare the server args.

start_server(*args: str) None[source]

Start the server.

django_prodserver.backends.waitress module

django_prodserver.backends.werkzeug module

Deprecated; see django_prodserver.backends.dev.werkzeug.

class django_prodserver.backends.werkzeug.RunserverPlus(**server_args: Any)[source]

Bases: WerkzeugRunserver

Alias for users coming from django-extensions runserver_plus.

class django_prodserver.backends.werkzeug.WerkzeugRunserver(**server_args: Any)[source]

Bases: BaseRunserverBackend

WSGI dev server backend driving werkzeug.serving.run_simple directly.

Mirrors django-extensions’ runserver_plus 1:1 over the standard ARGS dict. ARGS keys match runserver_plus CLI flags:

{
    "BACKEND": "django_prodserver.backends.dev.werkzeug.WerkzeugRunserver",
    "ARGS": {
        # base (shared with DjangoRunserver / DaphneRunserver):
        "addrport": "127.0.0.1:8000",
        "ipv6": False,
        "noreload": False,
        "nostatic": False,
        "insecure": False,
        # run_simple kwargs:
        "threaded": True,
        "nothreading": False,
        "processes": 1,
        "extra_files": [],
        "exclude_patterns": [],
        "reloader_type": "auto",
        "reloader_interval": 1,
        "passthrough_errors": False,
        # debugger:
        "use_debugger": True,
        "nopin": False,
        "trusted_hosts": [],
        "evalex": True,
        # ssl:
        "cert_file": None,
        "key_file": None,
        "ssl_dev_cert_dir": None,
        # ergonomics:
        "browser": False,
        "output": None,
        "print_sql": False,
        "truncate_sql": 1000,
        "print_sql_location": False,
        "pdb": False,
        "ipdb": False,
        "pm": False,
        "keep_meta_shutdown": False,
        "startup_messages": "reload",
    },
}

Werkzeug owns reloading: start_server does NOT wrap with django.utils.autoreload.run_with_reloader; instead run_simple is given use_reloader=... and forks/spawns its own child.

get_handler() Any[source]

Mirror runserver.get_handler + the staticfiles override.

server_kind: str = 'Werkzeug development'
start_server(*args: str) None[source]

Werkzeug owns reloading; do NOT wrap with django.utils.autoreload.