Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use ArgumentDefaultsHelpFormatter to show the defaults for rundramatiq options. #167

Merged
merged 3 commits into from
Dec 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletions django_dramatiq/management/commands/rundramatiq.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import argparse
import importlib
import multiprocessing
import os
Expand All @@ -19,75 +20,76 @@ class Command(BaseCommand):
help = "Runs Dramatiq workers."

def add_arguments(self, parser):
parser.formatter_class = argparse.ArgumentDefaultsHelpFormatter
parser.add_argument(
"--skip-logging",
action="store_true",
dest="skip_logging",
help="do not call logging.basicConfig()"
help="Do not call logging.basicConfig()"
)
parser.add_argument(
"--reload",
action="store_true",
dest="use_watcher",
help="Enable autoreload.",
help="Enable autoreload",
)
parser.add_argument(
"--reload-use-polling",
action="store_true",
dest="use_polling_watcher",
help=(
"Use a poll-based file watcher for autoreload (useful under "
"Vagrant and Docker for Mac)."
"Vagrant and Docker for Mac)"
),
)
parser.add_argument(
"--use-gevent",
action="store_true",
help="Use gevent for worker concurrency.",
help="Use gevent for worker concurrency",
)
parser.add_argument(
"--processes", "-p",
default=CPU_COUNT,
type=int,
help="The number of processes to run (default: %d)." % CPU_COUNT,
help="The number of processes to run",
)
parser.add_argument(
"--threads", "-t",
default=THREAD_COUNT,
type=int,
help="The number of threads per process to use (default: %d)." % THREAD_COUNT,
help="The number of threads per process to use",
)
parser.add_argument(
"--path", "-P",
default=".",
nargs="*",
type=str,
help="The import path (default: .).",
help="The import path",
)
parser.add_argument(
"--queues", "-Q",
nargs="*",
type=str,
help="listen to a subset of queues (default: all queues)",
help="Listen to a subset of queues, or all when empty",
)
parser.add_argument(
"--pid-file",
type=str,
help="write the PID of the master process to a file (default: no pid file)",
help="Write the PID of the master process to this file",
)
parser.add_argument(
"--log-file",
type=str,
help="write all logs to a file (default: sys.stderr)",
help="Write all logs to a file, or stderr when empty",
)
parser.add_argument(
"--fork-function",
action="append", dest="forks", default=[],
help="fork a subprocess to run the given function",
help="Fork a subprocess to run the given function",
)
parser.add_argument(
"--worker-shutdown-timeout", type=int, default=600000,
help="timeout for worker shutdown, in milliseconds (default: 10 minutes)"
help="Timeout for worker shutdown, in milliseconds"
)

def handle(self, use_watcher, skip_logging, use_polling_watcher, use_gevent, path, processes, threads, verbosity,
Expand Down