|
19 | 19 | 3: logging.DEBUG,
|
20 | 20 | }
|
21 | 21 |
|
| 22 | +WORKER_ARGUMENTS = { |
| 23 | + "name", |
| 24 | + "default_result_ttl", |
| 25 | + "connection", |
| 26 | + "exc_handler", |
| 27 | + "exception_handlers", |
| 28 | + "default_worker_ttl", |
| 29 | + "maintenance_interval", |
| 30 | + "job_class", |
| 31 | + "queue_class", |
| 32 | + "log_job_description", |
| 33 | + "job_monitoring_interval", |
| 34 | + "disable_default_exception_handler", |
| 35 | + "prepare_for_work", |
| 36 | + "serializer", |
| 37 | + "work_horse_killed_handler", |
| 38 | +} |
| 39 | + |
22 | 40 |
|
23 | 41 | def reset_db_connections():
|
24 | 42 | for c in connections.all():
|
@@ -80,30 +98,29 @@ def add_arguments(self, parser):
|
80 | 98 | parser.add_argument("--sentry-ca-certs", action="store", dest="sentry_ca_certs", help="Path to CA certs file")
|
81 | 99 |
|
82 | 100 | def handle(self, **options):
|
83 |
| - queues = options.get("queues", []) |
| 101 | + queues = options.pop("queues", []) |
84 | 102 | if not queues:
|
85 | 103 | queues = [
|
86 | 104 | "default",
|
87 | 105 | ]
|
88 | 106 | click.echo(f"Starting worker for queues {queues}")
|
89 |
| - pidfile = options.get("pidfile") |
| 107 | + pidfile = options.pop("pidfile") |
90 | 108 | if pidfile:
|
91 | 109 | with open(os.path.expanduser(pidfile), "w") as fp:
|
92 | 110 | fp.write(str(os.getpid()))
|
93 | 111 |
|
94 | 112 | # Verbosity is defined by default in BaseCommand for all commands
|
95 |
| - verbosity = options.get("verbosity", 1) |
| 113 | + verbosity = options.pop("verbosity", 1) |
96 | 114 | log_level = VERBOSITY_TO_LOG_LEVEL.get(verbosity, logging.INFO)
|
97 | 115 | setup_loghandlers(log_level)
|
98 | 116 |
|
| 117 | + init_options = {k: v for k, v in options.items() if k in WORKER_ARGUMENTS} |
| 118 | + |
99 | 119 | try:
|
100 | 120 | # Instantiate a worker
|
101 | 121 | w = create_worker(
|
102 | 122 | *queues,
|
103 |
| - name=options["name"], |
104 |
| - job_class=options.get("job_class"), |
105 |
| - default_worker_ttl=options["worker_ttl"], |
106 |
| - fork_job_execution=options["fork_job_execution"], |
| 123 | + **init_options |
107 | 124 | )
|
108 | 125 |
|
109 | 126 | # Close any opened DB connection before any fork
|
|
0 commit comments